33 require
'../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51 $langs->loadLangs(array(
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"));
53 $action =
GETPOST(
'action',
'aZ09');
54 $cancel =
GETPOST(
'cancel',
'alpha');
55 $backtopage =
GETPOST(
'backtopage',
'alpha');
56 $socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
57 $origin =
GETPOST(
'origin',
'alpha');
58 $originid =
GETPOST(
'originid',
'int');
59 $confirm =
GETPOST(
'confirm',
'alpha');
61 $fulldayevent =
GETPOST(
'fullday',
'alpha');
63 $aphour =
GETPOST(
'aphour',
'int');
64 $apmin =
GETPOST(
'apmin',
'int');
65 $p2hour =
GETPOST(
'p2hour',
'int');
66 $p2min =
GETPOST(
'p2min',
'int');
68 $addreminder =
GETPOST(
'addreminder',
'alpha');
69 $offsetvalue =
GETPOST(
'offsetvalue',
'int');
70 $offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
71 $remindertype =
GETPOST(
'selectremindertype',
'aZ09');
72 $modelmail =
GETPOST(
'actioncommsendmodel_mail',
'int');
73 $complete =
GETPOST(
'complete',
'alpha');
74 $private =
GETPOST(
'private',
'alphanohtml');
75 if ($complete ==
'na' || $complete == -2) {
82 $datep =
dol_mktime(
'00',
'00', 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
83 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
91 $socid =
GETPOST(
'socid',
'int');
93 if ($user->socid && ($socid != $user->socid)) {
98 $donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
111 if ($id > 0 && $action !=
'add') {
112 $ret = $object->fetch($id);
114 $ret = $object->fetch_optionals();
115 $ret1 = $object->fetch_userassigned();
117 if ($ret < 0 || $ret1 < 0) {
123 $extrafields->fetch_name_optionals_label($object->table_element);
126 $hookmanager->initHooks(array(
'actioncard',
'globalcard'));
129 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
134 $TRemindTypes = array();
135 if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) {
136 $TRemindTypes[
'browser'] = array(
'label'=>$langs->trans(
'BrowserPush'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_BROWSER) ? 1 : 0));
138 if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) {
139 $TRemindTypes[
'email'] = array(
'label'=>$langs->trans(
'EMail'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_EMAIL) ? 1 : 0));
142 $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'));
144 $result =
restrictedArea($user,
'agenda', $object->id,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
151 $listUserAssignedUpdated =
false;
153 if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
154 $idtoremove =
GETPOST(
'removedassigned');
156 if (!empty($_SESSION[
'assignedtouser'])) {
157 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'], 1);
159 $tmpassigneduserids = array();
162 foreach ($tmpassigneduserids as $key => $val) {
163 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
164 unset($tmpassigneduserids[$key]);
168 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
169 $donotclearsession = 1;
170 if ($action ==
'add') {
173 if ($action ==
'update') {
177 $listUserAssignedUpdated =
true;
181 if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
183 if (
GETPOST(
'assignedtouser') > 0) {
184 $assignedtouser = array();
185 if (!empty($_SESSION[
'assignedtouser'])) {
186 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
188 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id'=>
GETPOST(
'assignedtouser'),
'transparency'=>
GETPOST(
'transparency'),
'mandatory'=>1);
189 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
191 $donotclearsession = 1;
192 if ($action ==
'add') {
195 if ($action ==
'update') {
199 $listUserAssignedUpdated =
true;
203 if (empty($reshook) && $action ==
'classin' && ($user->rights->agenda->allactions->create ||
204 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) {
206 $object->setProject(
GETPOST(
'projectid',
'int'));
210 if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes') {
211 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
216 if (!empty($object->socpeopleassigned)) {
217 reset($object->socpeopleassigned);
218 $object->contact_id = key($object->socpeopleassigned);
220 $result = $object->createFromClone($user,
GETPOST(
'socid',
'int'));
222 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
233 if (empty($reshook) && $action ==
'add') {
236 if (empty($backtopage)) {
238 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
240 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
244 if (!empty($socpeopleassigned[0])) {
245 $result = $contact->fetch($socpeopleassigned[0]);
249 header(
"Location: ".$backtopage);
253 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
259 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
260 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
262 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
263 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
267 if (!$datef && $percentage == 100) {
268 $error++; $donotclearsession = 1;
270 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
273 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !
GETPOST(
'label')) {
274 $error++; $donotclearsession = 1;
276 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
281 $error++; $donotclearsession = 1;
283 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
285 $object->type_code =
GETPOST(
'actioncode',
'aZ09');
291 $object->fulldayevent = ($fulldayevent ? 1 : 0);
292 $object->location =
GETPOST(
"location",
'alphanohtml');
293 $object->label =
GETPOST(
'label',
'alphanohtml');
295 if (
GETPOST(
"elementtype",
'alpha')) {
296 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
298 $hasPermissionOnLinkedObject = 0;
299 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
300 $hasPermissionOnLinkedObject = 1;
302 if ($hasPermissionOnLinkedObject) {
303 $object->fk_element =
GETPOST(
"fk_element",
'int');
304 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
309 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
310 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
312 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
313 $object->label = $langs->transnoentitiesnoconv(
"Action".$object->type_code).
"\n";
315 $cactioncomm->fetch($object->type_code);
316 $object->label = $cactioncomm->label;
322 $taskid =
GETPOST(
'taskid',
'int');
323 if (!empty($taskid)) {
324 $taskProject =
new Task($db);
325 if ($taskProject->fetch($taskid) > 0) {
326 $object->fk_project = $taskProject->fk_project;
329 $object->fk_element = $taskid;
330 $object->elementtype =
'task';
333 $object->datep = $datep;
334 $object->datef = $datef;
335 $object->percentage = $percentage;
336 $object->duree = (((int)
GETPOST(
'dureehour') * 60) + (
int)
GETPOST(
'dureemin')) * 60;
338 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
340 $listofuserid = array();
341 if (!empty($_SESSION[
'assignedtouser'])) {
342 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
345 foreach ($listofuserid as $key => $value) {
347 if ($value[
'id'] > 0) {
348 $object->userownerid = $value[
'id'];
350 $object->transparency = $transparency;
353 $object->userassigned[$value[
'id']] = array(
'id'=>$value[
'id'],
'transparency'=>$transparency);
359 if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) {
361 $object->userdoneid =
GETPOST(
"doneby",
"int");
365 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
368 $object->contact = $contact;
371 if (
GETPOST(
'socid',
'int') > 0) {
372 $object->socid =
GETPOST(
'socid',
'int');
373 $object->fetch_thirdparty();
375 $object->societe = $object->thirdparty;
379 if (empty($object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
380 $error++; $donotclearsession = 1;
382 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
384 if ($object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
385 $error++; $donotclearsession = 1;
387 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
391 $error++; $donotclearsession = 1;
393 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
396 foreach ($socpeopleassigned as $cid) {
397 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
399 if (!empty($object->socpeopleassigned)) {
400 reset($object->socpeopleassigned);
401 $object->contact_id = key($object->socpeopleassigned);
405 $ret = $extrafields->setOptionalsFromPost(
null, $object);
414 $idaction = $object->create($user);
417 if (!$object->error) {
419 $categories =
GETPOST(
'categories',
'array');
420 $object->setCategories($categories);
422 unset($_SESSION[
'assignedtouser']);
425 if ($user->id != $object->userownerid) {
426 $moreparam =
"filtert=-1";
430 if ($addreminder ==
'on') {
435 $actionCommReminder->dateremind = $dateremind;
436 $actionCommReminder->typeremind = $remindertype;
437 $actionCommReminder->offsetunit = $offsetunit;
438 $actionCommReminder->offsetvalue = $offsetvalue;
439 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
440 $actionCommReminder->fk_actioncomm = $object->id;
441 if ($remindertype ==
'email') {
442 $actionCommReminder->fk_email_template = $modelmail;
446 foreach ($object->userassigned as $userassigned) {
447 $actionCommReminder->fk_user = $userassigned[
'id'];
448 $res = $actionCommReminder->create($user);
453 $langs->load(
"errors");
454 $error = $langs->trans(
'ErrorReminderActionCommCreation');
456 $action =
'create'; $donotclearsession = 1;
467 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
475 if (!empty($backtopage)) {
476 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
477 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
478 } elseif ($idaction) {
479 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
481 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
487 $langs->load(
"errors");
488 $error = $langs->trans($object->error);
490 $action =
'create'; $donotclearsession = 1;
495 $action =
'create'; $donotclearsession = 1;
503 if (empty($reshook) && $action ==
'update') {
504 if (empty($cancel)) {
505 $fulldayevent =
GETPOST(
'fullday');
506 $aphour =
GETPOST(
'aphour',
'int');
507 $apmin =
GETPOST(
'apmin',
'int');
508 $p2hour =
GETPOST(
'p2hour',
'int');
509 $p2min =
GETPOST(
'p2min',
'int');
510 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
527 $object->fetch_optionals();
528 $object->fetch_userassigned();
529 $object->oldcopy = clone $object;
535 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
536 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
538 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
539 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
542 if ($object->elementtype ==
'ticket') {
544 $object->type_code =
'TICKET_MSG_PRIVATE';
550 $object->type_code =
GETPOST(
"actioncode",
'aZ09');
553 $object->label =
GETPOST(
"label",
"alphanohtml");
554 $object->datep = $datep;
555 $object->datef = $datef;
556 $object->percentage = $percentage;
557 $object->priority =
GETPOST(
"priority",
"int");
558 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
559 $object->location =
GETPOST(
'location',
"alphanohtml");
560 $object->socid =
GETPOST(
"socid",
"int");
561 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
562 $object->socpeopleassigned = array();
563 foreach ($socpeopleassigned as $cid) {
564 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
566 $object->contact_id =
GETPOST(
"contactid",
'int');
567 if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
568 reset($object->socpeopleassigned);
569 $object->contact_id = key($object->socpeopleassigned);
571 $object->fk_project =
GETPOST(
"projectid",
'int');
572 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
574 if (
GETPOST(
"elementtype",
'alpha')) {
575 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
577 $hasPermissionOnLinkedObject = 0;
578 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
579 $hasPermissionOnLinkedObject = 1;
581 if ($hasPermissionOnLinkedObject) {
582 $object->fk_element =
GETPOST(
"fk_element",
'int');
583 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
587 if (!$datef && $percentage == 100) {
588 $error++; $donotclearsession = 1;
589 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), $object->errors,
'errors');
593 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
596 $listofuserid = array();
597 if (!empty($_SESSION[
'assignedtouser'])) {
599 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
600 foreach ($tmplist1 as $key => $val) {
601 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
602 $listofuserid[$val[
'id']] = $val;
606 $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
607 if ($assignedtouser) {
608 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>($user->id == $assignedtouser ? $transparency :
''));
611 $object->userassigned = array(); $object->userownerid = 0;
613 foreach ($listofuserid as $key => $val) {
615 $object->userownerid = $val[
'id'];
617 $object->userassigned[$val[
'id']] = array(
'id'=>$val[
'id'],
'mandatory'=>0,
'transparency'=>($user->id == $val[
'id'] ? $transparency :
''));
621 $object->transparency = $transparency;
624 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
626 $object->userdoneid =
GETPOST(
"doneby",
"int");
632 $error++; $donotclearsession = 1;
634 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
636 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
638 if (empty($object->userownerid)) {
639 $error++; $donotclearsession = 1;
641 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
645 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
652 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
653 $eventDateStart = $object->datep;
654 $eventDateEnd = $object->datef;
656 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
657 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
658 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
659 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
660 $sql .=
" WHERE ac.id <> ".((int) $object->id);
661 $sql .=
" AND er.resource_id IN (";
662 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
663 $sql .=
" WHERE element_id = ".((int) $object->id);
664 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
665 $sql .=
" AND busy = 1";
667 $sql .=
" AND er.busy = 1";
671 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
673 if (!empty($eventDateEnd)) {
674 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
678 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
679 if (!empty($eventDateEnd)) {
680 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
685 $resql = $db->query($sql);
688 $object->error = $db->lasterror();
689 $object->errors[] = $object->error;
691 if ($db->num_rows(
$resql) > 0) {
694 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
695 while ($obj = $db->fetch_object(
$resql)) {
696 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
698 $object->errors[] = $object->error;
712 $result = $object->update($user);
716 $categories =
GETPOST(
'categories',
'array');
717 $object->setCategories($categories);
719 $object->loadReminders($remindertype, 0,
false);
720 if (!empty($object->reminders) && $object->datep >
dol_now()) {
721 foreach ($object->reminders as $reminder) {
722 $reminder->delete($user);
724 $object->reminders = array();
728 if ($addreminder ==
'on' && $object->datep >
dol_now()) {
733 $actionCommReminder->dateremind = $dateremind;
734 $actionCommReminder->typeremind = $remindertype;
735 $actionCommReminder->offsetunit = $offsetunit;
736 $actionCommReminder->offsetvalue = $offsetvalue;
737 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
738 $actionCommReminder->fk_actioncomm = $object->id;
739 if ($remindertype ==
'email') {
740 $actionCommReminder->fk_email_template = $modelmail;
744 foreach ($object->userassigned as $userassigned) {
745 $actionCommReminder->fk_user = $userassigned[
'id'];
746 $res = $actionCommReminder->create($user);
750 $langs->load(
"errors");
751 $error = $langs->trans(
'ErrorReminderActionCommCreation');
753 $action =
'create'; $donotclearsession = 1;
759 unset($_SESSION[
'assignedtouser']);
774 if (!empty($backtopage)) {
775 unset($_SESSION[
'assignedtouser']);
776 header(
"Location: ".$backtopage);
785 if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
787 $object->fetch_optionals();
788 $object->fetch_userassigned();
789 $object->oldcopy = clone $object;
791 if ($user->rights->agenda->myactions->delete
792 || $user->rights->agenda->allactions->delete) {
793 $result = $object->delete();
796 header(
"Location: index.php");
808 if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
814 $newdate =
GETPOST(
'newdate',
'alpha');
815 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
816 header(
"Location: ".$backtopage);
820 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
823 if ($datep != $object->datep) {
824 if (!empty($object->datef)) {
825 $object->datef += $datep - $object->datep;
827 $object->datep = $datep;
831 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
832 $eventDateStart = $object->datep;
833 $eventDateEnd = $object->datef;
835 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
836 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
837 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
838 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
839 $sql .=
" WHERE ac.id <> ".((int) $object->id);
840 $sql .=
" AND er.resource_id IN (";
841 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
842 $sql .=
" WHERE element_id = ".((int) $object->id);
843 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
844 $sql .=
" AND busy = 1";
846 $sql .=
" AND er.busy = 1";
850 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
852 if (!empty($eventDateEnd)) {
853 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
857 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
858 if (!empty($eventDateEnd)) {
859 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
864 $resql = $db->query($sql);
867 $object->error = $db->lasterror();
868 $object->errors[] = $object->error;
870 if ($db->num_rows(
$resql) > 0) {
873 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
874 while ($obj = $db->fetch_object(
$resql)) {
875 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
877 $object->errors[] = $object->error;
890 $result = $object->update($user);
900 if (!empty($backtopage)) {
901 header(
"Location: ".$backtopage);
910 $permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read));
911 if (empty($reshook)) {
912 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
924 $arrayrecurrulefreq = array(
925 'no'=>$langs->trans(
"OnceOnly"),
926 'MONTHLY'=>$langs->trans(
"EveryMonth"),
927 'WEEKLY'=>$langs->trans(
"EveryWeek"),
931 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
934 if ($action ==
'create') {
937 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
938 if (!empty($socpeopleassigned[0])) {
939 $result = $contact->fetch($socpeopleassigned[0]);
947 if (!empty($conf->use_javascript_ajax)) {
948 print
"\n".
'<script type="text/javascript">';
949 print
'$(document).ready(function () {
950 function setdatefields()
952 if ($("#fullday:checked").val() == null) {
953 $(".fulldaystarthour").removeAttr("disabled");
954 $(".fulldaystartmin").removeAttr("disabled");
955 $(".fulldayendhour").removeAttr("disabled");
956 $(".fulldayendmin").removeAttr("disabled");
957 $("#p2").removeAttr("disabled");
959 $(".fulldaystarthour").prop("disabled", true).val("00");
960 $(".fulldaystartmin").prop("disabled", true).val("00");
961 $(".fulldayendhour").prop("disabled", true).val("23");
962 $(".fulldayendmin").prop("disabled", true).val("59");
963 $("#p2").removeAttr("disabled");
966 $("#fullday").change(function() {
967 console.log("setdatefields");
971 $("#selectcomplete").change(function() {
972 console.log("we change the complete status - set the doneby");
973 if ($("#selectcomplete").val() == 100) {
974 if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).
'\');
976 if ($(
"#selectcomplete").val() == 0) {
977 $(
"#doneby").val(-1);
981 $(
"#actioncode").change(
function() {
982 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
983 else $("#dateend").removeClass("fieldrequired");
985 $("#aphour,#apmin").change(function() {
986 if ($("#actioncode").val() == \'AC_RDV\') {
987 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
988 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
989 $("#p2min").val($("#apmin").val());
990 $("#p2day").val($("#apday").val());
991 $("#p2month").val($("#apmonth").val());
992 $("#p2year").val($("#apyear").val());
993 $("#p2").val($("#ap").val());
996 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
997 else $("#dateend").removeClass("fieldrequired");
1000 print
'</script>'.
"\n";
1003 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1004 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1005 print
'<input type="hidden" name="action" value="add">';
1006 print
'<input type="hidden" name="donotclearsession" value="1">';
1007 print
'<input type="hidden" name="page_y" value="">';
1009 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
dol_htmlentities($_SERVER[
"HTTP_REFERER"])).
'">';
1011 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1012 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1015 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1016 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1023 print
'<table class="border centpercent">';
1026 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1027 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1028 $default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ?
'AC_RDV' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT);
1029 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1030 print
$formactions->select_type_actions(
GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : ($object->type_code ? $object->type_code : $default),
"actioncode",
"systemauto", 0, -1, 0, 1);
1035 print
'<tr><td'.(empty($conf->global->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>';
1038 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" '.(
GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1041 $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1042 if ($userepeatevent) {
1045 print
' <div class="opacitymedium inline-block">';
1046 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1047 print
'<input type="hidden" name="recurid" value="'.(empty($object->recurid) ?
'' : $object->recurid).
'">';
1048 $selectedrecurrulefreq =
'no';
1049 $selectedrecurrulebymonthday =
'';
1050 $selectedrecurrulebyday =
'';
1052 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1053 $selectedrecurrulefreq = $reg[1];
1055 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) {
1056 $selectedrecurrulebymonthday = $reg[1];
1058 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1059 $selectedrecurrulebyday = $reg[1];
1061 print
$form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1063 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1064 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1067 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1068 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1070 print
'<script type="text/javascript">
1071 jQuery(document).ready(function() {
1072 function init_repeat()
1074 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1076 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1077 jQuery(".repeateventBYDAY").hide();
1079 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1081 jQuery(".repeateventBYMONTHDAY").hide();
1082 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1086 jQuery(".repeateventBYMONTHDAY").hide();
1087 jQuery(".repeateventBYDAY").hide();
1091 jQuery("#recurrulefreq").change(function() {
1102 $datep = ($datep ? $datep : (is_null($object->datep) ?
'' : $object->datep));
1103 if (
GETPOST(
'datep',
'int', 1)) {
1106 $datef = ($datef ? $datef : $object->datef);
1107 if (
GETPOST(
'datef',
'int', 1)) {
1110 if (empty($datef) && !empty($datep)) {
1111 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
1112 $datef =
dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS),
'h');
1117 print
'<tr><td class="nowrap">';
1125 print
$form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1127 print
$form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1129 print
' <span class="hideonsmartphone"> - </span> ';
1131 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1133 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1137 print
'<tr><td class=""> </td><td></td></tr>';
1140 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1141 $listofuserid = array();
1142 $listofcontactid = array();
1143 $listofotherid = array();
1145 if (empty($donotclearsession)) {
1146 $assignedtouser =
GETPOST(
"assignedtouser") ?
GETPOST(
"assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1147 if ($assignedtouser) {
1148 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>$object->transparency);
1151 $listofuserid[$assignedtouser][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1152 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1154 if (!empty($_SESSION[
'assignedtouser'])) {
1155 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1157 $firstelem = reset($listofuserid);
1158 if (isset($listofuserid[$firstelem[
'id']])) {
1159 $listofuserid[$firstelem[
'id']][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1162 print
'<div class="assignedtouser">';
1163 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1168 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1169 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1170 print
$form->select_dolusers(
GETPOSTISSET(
"doneby") ?
GETPOST(
"doneby",
'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0),
'doneby', 1);
1175 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1176 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>';
1180 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1182 $percent = $complete !==
'' ? $complete : -1;
1186 $percent =
GETPOST(
'percentage',
'int');
1188 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1190 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1194 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1197 if (!empty($conf->categorie->enabled)) {
1199 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1200 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1201 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1208 print
'<br><hr><br>';
1211 print
'<table class="border centpercent">';
1213 if (!empty($conf->societe->enabled)) {
1215 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1216 if (
GETPOST(
'socid',
'int') > 0) {
1218 $societe->fetch(
GETPOST(
'socid',
'int'));
1219 print $societe->getNomUrl(1);
1220 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOST(
'socid',
'int').
'">';
1223 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1225 if (!empty($user->socid)) {
1226 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300');
1228 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
1234 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1235 $preselectedids =
GETPOST(
'socpeopleassigned',
'array');
1236 if (
GETPOST(
'contactid',
'int')) {
1237 $preselectedids[
GETPOST(
'contactid',
'int')] =
GETPOST(
'contactid',
'int');
1239 if ($origin==
'contact') $preselectedids[
GETPOST(
'originid',
'int')] =
GETPOST(
'originid',
'int');
1240 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1241 print
$form->selectcontacts(
GETPOST(
'socid',
'int'), $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 quatrevingtpercent',
false, 0, array(),
false,
'multiple',
'contactid');
1246 if (!empty($conf->project->enabled)) {
1247 $langs->load(
"projects");
1249 $projectid =
GETPOST(
'projectid',
'int');
1251 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1252 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1253 print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
1255 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1256 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1257 $urloption =
'?action=create&donotclearsession=1';
1261 print
"\n".
'<script type="text/javascript">';
1262 print
'$(document).ready(function () {
1263 $("#projectid").change(function () {
1264 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1265 console.log("Call url to get new list of tasks: "+url);
1266 $.get(url, function(data) {
1268 if (data) $("#taskid").html(data).select2();
1272 print
'</script>'.
"\n";
1276 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1277 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1278 $projectsListId =
false;
1279 if (!empty($projectid)) {
1280 $projectsListId = $projectid;
1285 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500', $projectsListId);
1290 if (!empty($origin) && !empty($originid)) {
1291 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1293 $hasPermissionOnLinkedObject = 0;
1294 if ($user->hasRight($origin,
'read')) {
1295 $hasPermissionOnLinkedObject = 1;
1299 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1301 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1302 print
'<td colspan="3">';
1303 if ($hasPermissionOnLinkedObject) {
1305 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1306 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1307 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1308 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1310 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1317 if (
GETPOST(
"datep") && preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
1318 $object->datep =
dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
1322 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1323 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1324 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOST(
'priority',
'int') : ($object->priority ? $object->priority :
'')).
'" size="5">';
1329 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1330 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1331 $doleditor =
new DolEditor(
'note', (
GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') : $object->note_private),
'', 120,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1332 $doleditor->Create();
1337 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1338 print $hookmanager->resPrint;
1339 if (empty($reshook)) {
1340 print $object->showOptionals($extrafields,
'create',
$parameters);
1350 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1352 print
'<div class="reminderparameters" style="display: none;">';
1357 print
'<table class="border centpercent">';
1360 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1361 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOST(
'offsetvalue',
'int') :
'15').
'"> ';
1362 print
$form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1366 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1367 print
$form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1372 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1373 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1380 print
"\n".
'<script type="text/javascript">';
1381 print
'$(document).ready(function () {
1382 $("#addreminder").click(function(){
1383 console.log("Click on addreminder");
1385 $(".reminderparameters").show();
1387 $(".reminderparameters").hide();
1389 $("#selectremindertype").select2("destroy");
1390 $("#selectremindertype").select2();
1391 $("#select_offsetunittype_duration").select2("destroy");
1392 $("#select_offsetunittype_duration").select2();
1395 $("#selectremindertype").change(function(){
1396 console.log("Change on selectremindertype");
1397 var selected_option = $("#selectremindertype option:selected").val();
1398 if(selected_option == "email") {
1399 $("#select_actioncommsendmodel_mail").closest("tr").show();
1401 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1405 print
'</script>'.
"\n";
1410 print
$form->buttonsSaveCancel(
"Add");
1417 $result1 = $object->fetch($id);
1418 if ($result1 <= 0) {
1419 $langs->load(
"errors");
1420 print $langs->trans(
"ErrorRecordNotFound");
1426 $result2 = $object->fetch_thirdparty();
1427 $result2 = $object->fetch_projet();
1428 $result3 = $object->fetch_contact();
1429 $result4 = $object->fetch_userassigned();
1430 $result5 = $object->fetch_optionals();
1432 if ($listUserAssignedUpdated || $donotclearsession) {
1433 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
1435 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
1436 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
1439 $object->label =
GETPOST(
"label",
"alphanohtml");
1440 $object->datep = $datep;
1441 $object->datef = $datef;
1442 $object->percentage = $percentage;
1443 $object->priority =
GETPOST(
"priority",
"alphanohtml");
1444 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
1445 $object->location =
GETPOST(
'location',
"alpanohtml");
1446 $object->socid =
GETPOST(
"socid",
"int");
1447 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1448 foreach ($socpeopleassigned as $tmpid) {
1449 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1451 $object->contact_id =
GETPOST(
"contactid",
'int');
1452 $object->fk_project =
GETPOST(
"projectid",
'int');
1454 $object->note_private =
GETPOST(
"note",
'restricthtml');
1457 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1462 if ($object->authorid > 0) {
1463 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
1465 if ($object->usermodid > 0) {
1466 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
1477 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1481 if ($action ==
'delete') {
1482 print
$form->formconfirm(
"card.php?id=".urlencode($id), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1485 if ($action ==
'edit') {
1486 if (!empty($conf->use_javascript_ajax)) {
1487 print
"\n".
'<script type="text/javascript">';
1488 print
'$(document).ready(function () {
1489 function setdatefields()
1491 if ($("#fullday:checked").val() == null) {
1492 $(".fulldaystarthour").removeAttr("disabled");
1493 $(".fulldaystartmin").removeAttr("disabled");
1494 $(".fulldayendhour").removeAttr("disabled");
1495 $(".fulldayendmin").removeAttr("disabled");
1497 $(".fulldaystarthour").prop("disabled", true).val("00");
1498 $(".fulldaystartmin").prop("disabled", true).val("00");
1499 $(".fulldayendhour").prop("disabled", true).val("23");
1500 $(".fulldayendmin").prop("disabled", true).val("59");
1504 $("#fullday").change(function() {
1507 $("#actioncode").change(function() {
1508 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1509 else $("#dateend").removeClass("fieldrequired");
1512 print
'</script>'.
"\n";
1515 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1516 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1517 print
'<input type="hidden" name="action" value="update">';
1518 print
'<input type="hidden" name="id" value="'.$id.
'">';
1519 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1520 print
'<input type="hidden" name="page_y" value="">';
1522 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
dol_htmlentities($_SERVER[
"HTTP_REFERER"])).
'">';
1524 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->code !=
"TICKET_MSG_PRIVATE") {
1525 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1530 print
'<table class="border tableforfield" width="100%">';
1533 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.$object->id.
'</td></tr>';
1536 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->elementtype !=
"ticket") {
1537 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1538 if ($object->type_code !=
'AC_OTH_AUTO') {
1539 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1540 print
$formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') : $object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1542 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1543 print $object->getTypePicto();
1544 print $langs->trans(
"Action".$object->type_code);
1550 if ($object->elementtype ==
'ticket') print
'<tr><td>'.$langs->trans(
"PrivateEventMessage").
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(($object->code ==
'TICKET_MSG_PRIVATE') ?
' checked' :
'').
'></td></tr>';
1553 print
'<tr><td'.(empty($conf->global->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>';
1556 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' :
'').
'>';
1557 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1560 $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1561 if ($userepeatevent) {
1564 print
' <div class="opacitymedium inline-block">';
1565 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1566 print
'<input type="hidden" name="recurid" value="'.$object->recurid.
'">';
1567 $selectedrecurrulefreq =
'no';
1568 $selectedrecurrulebymonthday =
'';
1569 $selectedrecurrulebyday =
'';
1570 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1571 $selectedrecurrulefreq = $reg[1];
1573 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) {
1574 $selectedrecurrulebymonthday = $reg[1];
1576 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1577 $selectedrecurrulebyday = $reg[1];
1579 print
$form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1581 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1582 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1585 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1586 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1588 print
'<script type="text/javascript">
1589 jQuery(document).ready(function() {
1590 function init_repeat()
1592 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1594 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1595 jQuery(".repeateventBYDAY").hide();
1597 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1599 jQuery(".repeateventBYMONTHDAY").hide();
1600 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1604 jQuery(".repeateventBYMONTHDAY").hide();
1605 jQuery(".repeateventBYDAY").hide();
1609 jQuery("#recurrulefreq").change(function() {
1620 print
'<tr><td class="nowrap">';
1625 print
'</td><td td colspan="3">';
1628 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 0,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1629 } elseif (
GETPOST(
"afaire") == 2) {
1630 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1632 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1634 print
' <span class="hideonsmartphone"> - </span> ';
1636 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1637 } elseif (
GETPOST(
"afaire") == 2) {
1638 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1640 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1644 print
'<tr><td class=""> </td><td></td></tr>';
1647 $listofuserid = array();
1648 if (empty($donotclearsession)) {
1649 if ($object->userownerid > 0) {
1650 $listofuserid[$object->userownerid] = array(
1651 'id'=>$object->userownerid,
1654 'transparency'=>$object->transparency,
1655 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
1656 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
1659 if (!empty($object->userassigned)) {
1661 $tmplist1 = $object->userassigned;
1662 foreach ($tmplist1 as $key => $val) {
1663 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
1664 $listofuserid[$val[
'id']] = $val;
1668 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1670 if (!empty($_SESSION[
'assignedtouser'])) {
1671 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1674 $listofcontactid = $object->socpeopleassigned;
1675 $listofotherid = $object->otherassigned;
1677 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
1678 print
'<div class="assignedtouser">';
1679 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1690 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1691 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td colspan="3">';
1692 print
$form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1,
'doneby', 1);
1697 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1698 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="width500" value="'.$object->location.
'"></td></tr>';
1702 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
1703 $percent =
GETPOSTISSET(
"percentage") ?
GETPOST(
"percentage",
"int") : $object->percentage;
1704 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1708 if (!empty($conf->categorie->enabled)) {
1709 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1710 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1712 $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
1713 $arrayselected = array();
1714 foreach ($cats as $cat) {
1715 $arrayselected[] = $cat->id;
1717 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1724 print
'<br><hr><br>';
1727 print
'<table class="border tableforfield centpercent">';
1729 if (!empty($conf->societe->enabled)) {
1731 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
1733 print
'<div class="maxwidth200onsmartphone">';
1735 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1738 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth200');
1743 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
1744 print
'<div class="maxwidth200onsmartphone">';
1745 print
img_picto(
'',
'contact',
'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'quatrevingtpercent',
false, 0, 0, array(),
'multiple',
'contactid');
1752 if (!empty($conf->project->enabled)) {
1753 $langs->load(
"projects");
1755 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
1756 print
img_picto(
'',
'project',
'class="paddingrightonly"');
1757 $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth500');
1758 if ($numprojet == 0) {
1759 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>';
1765 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1766 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
1767 print
'<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
1772 if (!empty($object->fk_element) && !empty($object->elementtype)) {
1773 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1775 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
1777 if ($object->elementtype ==
'task' && !empty($conf->project->enabled)) {
1778 print
'<td id="project-task-input-container" >';
1780 $urloption =
'?action=create&donotclearsession=1';
1781 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
1784 print
"\n".
'<script type="text/javascript" >';
1785 print
'$(document).ready(function () {
1786 $("#projectid").change(function () {
1787 var url = "'.$url.
'&projectid="+$("#projectid").val();
1788 $.get(url, function(data) {
1789 console.log($( data ).find("#fk_element").html());
1790 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
1794 print
'</script>'.
"\n";
1796 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
1797 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
1803 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
1804 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
1812 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1814 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1815 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, $conf->fckeditor->enabled, ROWS_4,
'90%');
1816 $doleditor->Create();
1821 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1822 print $hookmanager->resPrint;
1823 if (empty($reshook)) {
1824 print $object->showOptionals($extrafields,
'edit',
$parameters);
1830 if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) {
1831 $filteruserid = $user->id;
1832 if ($user->rights->agenda->allactions->read) {
1835 $object->loadReminders(
'', $filteruserid,
false);
1839 if (count($object->reminders) > 0) {
1840 $checked =
'checked';
1841 $keys = array_keys($object->reminders);
1842 $firstreminderId = array_shift($keys);
1844 $actionCommReminder = $object->reminders[$firstreminderId];
1848 $actionCommReminder->offsetvalue = 10;
1849 $actionCommReminder->offsetunit =
'i';
1850 $actionCommReminder->typeremind =
'email';
1853 print
'<label for="addreminder">'.$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder" '.$checked.
'><br>';
1855 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
1859 print
'<table class="border centpercent">';
1862 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1863 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
1864 print
$form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
1868 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1869 print
$form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
1873 if ($actionCommReminder->typeremind ==
'browser') {
1874 $hide =
'style="display:none;"';
1878 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1879 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1884 print
"\n".
'<script type="text/javascript">';
1885 print
'$(document).ready(function () {
1886 $("#addreminder").click(function(){
1888 $(".reminderparameters").show();
1890 $(".reminderparameters").hide();
1894 $("#selectremindertype").change(function(){
1895 var selected_option = $("#selectremindertype option:selected").val();
1896 if(selected_option == "email") {
1897 $("#select_actioncommsendmodel_mail").closest("tr").show();
1899 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1904 print
'</script>'.
"\n";
1911 print
$form->buttonsSaveCancel();
1918 if ($action ==
'clone') {
1919 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', $formquestion,
'yes', 1);
1926 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
1927 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
1928 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
1929 $linkback .=
'</a>';
1930 $linkback .=
'</li>';
1931 $linkback .=
'<li class="noborder litext">';
1932 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_month&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
1933 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
1934 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
1935 $linkback .=
'</a>';
1936 $linkback .=
'</li>';
1937 $linkback .=
'<li class="noborder litext">';
1938 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_week&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
1939 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
1940 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
1941 $linkback .=
'</a>';
1942 $linkback .=
'</li>';
1943 $linkback .=
'<li class="noborder litext">';
1944 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
1945 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
1946 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
1947 $linkback .=
'</a>';
1948 $linkback .=
'</li>';
1949 $linkback .=
'<li class="noborder litext">';
1950 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=show_peruser&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
1951 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
1952 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
1953 $linkback .=
'</a>';
1957 $morehtmlref =
'<div class="refidno">';
1961 if (!empty($conf->project->enabled)) {
1962 $langs->load(
"projects");
1964 $morehtmlref .= $langs->trans(
'Project').
' ';
1965 if ($user->rights->agenda->allactions->create ||
1966 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
1967 if ($action !=
'classify') {
1968 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
1970 if ($action ==
'classify') {
1972 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
1973 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1974 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1975 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
1976 $morehtmlref .=
'<input type="submit" class="button button-save valignmiddle" value="'.$langs->trans(
"Modify").
'">';
1977 $morehtmlref .=
'</form>';
1979 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
1982 if (!empty($object->fk_project)) {
1984 $proj->fetch($object->fk_project);
1985 $morehtmlref .=
' : '.$proj->getNomUrl(1);
1987 $morehtmlref .=
' - '.$proj->title;
1994 $morehtmlref .=
'</div>';
1997 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
1999 print
'<div class="fichecenter">';
2000 print
'<div class="fichehalfleft">';
2002 print
'<div class="underbanner clearboth"></div>';
2005 print
'<table class="border tableforfield" width="100%">';
2008 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->elementtype !=
'ticket') {
2009 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2010 print $object->getTypePicto();
2011 print $langs->trans(
"Action".$object->type_code);
2016 if ($object->elementtype ==
'ticket') print
'<tr><td class="titlefield">'.$langs->trans(
"PrivateEventMessage").
'</td><td>'.
yn(($object->code ==
'TICKET_MSG_PRIVATE') ? 1 : 0, 3).
'</td></tr>';
2019 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2022 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2027 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2032 if (empty($object->fulldayevent)) {
2036 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2038 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2045 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2046 if (empty($object->fulldayevent)) {
2050 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2052 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2058 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2059 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
2063 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2064 $listofuserid = array();
2065 if (empty($donotclearsession)) {
2066 if ($object->userownerid > 0) {
2067 $listofuserid[$object->userownerid] = array(
2068 'id'=>$object->userownerid,
2069 'transparency'=>$object->transparency,
2070 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2071 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2074 if (!empty($object->userassigned)) {
2076 $tmplist1 = $object->userassigned;
2077 foreach ($tmplist1 as $key => $val) {
2078 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2079 $listofuserid[$val[
'id']] = $val;
2083 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2085 if (!empty($_SESSION[
'assignedtouser'])) {
2086 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2090 $listofcontactid = array();
2091 $listofotherid = array();
2092 print
'<div class="assignedtouser">';
2093 print
$form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2103 print
' </td></tr>';
2106 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
2107 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
2108 if ($object->userdoneid > 0) {
2109 $tmpuser =
new User($db);
2110 $tmpuser->fetch($object->userdoneid);
2111 print $tmpuser->getNomUrl(1);
2117 if (!empty($conf->categorie->enabled)) {
2118 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2119 print
$form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2127 print
'<div class="fichehalfright">';
2129 print
'<div class="underbanner clearboth"></div>';
2130 print
'<table class="border tableforfield centpercent">';
2132 if (!empty($conf->societe->enabled)) {
2134 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td><td>'.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2135 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL') {
2136 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2137 print
"<br>".dol_print_phone($object->thirdparty->phone);
2143 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2146 if (!empty($object->socpeopleassigned)) {
2147 foreach ($object->socpeopleassigned as $cid => $Tab) {
2149 $result = $contact->fetch($cid);
2156 print $contact->getNomUrl(1);
2157 if ($object->type_code ==
'AC_TEL') {
2158 if (!empty($contact->phone_pro)) {
2159 print
'('.dol_print_phone($contact->phone_pro).
')';
2162 print
'<div class="paddingright"></div>';
2166 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2172 print
'<tr><td class="nowrap" class="titlefield">'.$langs->trans(
"Priority").
'</td><td>';
2173 print ($object->priority ? $object->priority :
'');
2178 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project'))) {
2179 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2180 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2184 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2192 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
2197 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2200 if (!empty($conf->global->AGENDA_REMINDER_EMAIL) || !empty($conf->global->AGENDA_REMINDER_BROWSER)) {
2201 $filteruserid = $user->id;
2202 if ($user->rights->agenda->allactions->read) {
2205 $object->loadReminders(
'', $filteruserid,
false);
2207 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2209 if (count($object->reminders) > 0) {
2210 $tmpuserstatic =
new User($db);
2212 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2213 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2214 if ($actioncommreminder->fk_user > 0) {
2215 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2216 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2218 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2219 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2220 print
' - <span class="opacitymedium">';
2221 print $langs->trans(
"NotSent");
2223 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2224 print
' - <span class="opacitymedium">';
2225 print $langs->trans(
"Done");
2239 print
'<div class="clearboth"></div>';
2248 print
'<div class="tabsAction">';
2251 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2252 if (empty($reshook)) {
2253 if ($action !=
'edit') {
2254 if ($user->rights->agenda->allactions->create ||
2255 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2256 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2258 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2261 if ($user->rights->agenda->allactions->create ||
2262 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2263 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>';
2265 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2268 if ($user->rights->agenda->allactions->delete ||
2269 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) {
2270 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2272 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2279 if ($action !=
'edit') {
2280 if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) {
2281 print
'<div style="clear:both;"></div><div class="fichecenter"><div class="fichehalfleft">';
2282 print
'<a name="builddoc"></a>';
2288 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2289 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2291 $genallowed = $user->rights->agenda->myactions->read;
2292 $delallowed = $user->rights->agenda->myactions->create;
2295 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2297 print
'</div><div class="fichehalfright">';
2300 print
'</div></div>';