34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
53$langs->loadLangs(array(
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"));
56$action =
GETPOST(
'action',
'aZ09');
57$cancel =
GETPOST(
'cancel',
'alpha');
58$backtopage =
GETPOST(
'backtopage',
'alpha');
59$socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
60$origin =
GETPOST(
'origin',
'alpha');
61$originid =
GETPOST(
'originid',
'int');
62$confirm =
GETPOST(
'confirm',
'alpha');
64$fulldayevent =
GETPOST(
'fullday',
'alpha');
66$aphour =
GETPOST(
'aphour',
'int');
67$apmin =
GETPOST(
'apmin',
'int');
68$p2hour =
GETPOST(
'p2hour',
'int');
69$p2min =
GETPOST(
'p2min',
'int');
71$addreminder =
GETPOST(
'addreminder',
'alpha');
73$offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
74$remindertype =
GETPOST(
'selectremindertype',
'aZ09');
75$modelmail =
GETPOST(
'actioncommsendmodel_mail',
'int');
76$complete =
GETPOST(
'complete',
'alpha');
77$private =
GETPOST(
'private',
'alphanohtml');
78if ($complete ==
'na' || $complete == -2) {
85 $datep =
dol_mktime(
'00',
'00', 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
86 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
94 if (
GETPOST(
'datep') ==
'now') {
96 } elseif (preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
97 $datep =
dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1],
'tzuserrel');
102$socid =
GETPOST(
'socid',
'int');
104if ($user->socid && ($socid != $user->socid)) {
109$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
118$form =
new Form($db);
123if ($id > 0 && $action !=
'add') {
124 $ret = $object->fetch($id);
126 $ret = $object->fetch_optionals();
127 $ret1 = $object->fetch_userassigned();
129 if ($ret < 0 || $ret1 < 0) {
135$extrafields->fetch_name_optionals_label($object->table_element);
138$hookmanager->initHooks(array(
'actioncard',
'globalcard'));
140$parameters = array(
'socid' => $socid);
141$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
146$TRemindTypes = array();
148 $TRemindTypes[
'browser'] = array(
'label'=>$langs->trans(
'BrowserPush'),
'disabled'=>(!
getDolGlobalString(
'AGENDA_REMINDER_BROWSER') ? 1 : 0));
151 $TRemindTypes[
'email'] = array(
'label'=>$langs->trans(
'EMail'),
'disabled'=>(!
getDolGlobalString(
'AGENDA_REMINDER_EMAIL') ? 1 : 0));
154$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'));
156$result =
restrictedArea($user,
'agenda', $object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
158$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
165$listUserAssignedUpdated =
false;
166$listResourceAssignedUpdated =
false;
169if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
170 $idtoremove =
GETPOST(
'removedassigned');
172 if (!empty($_SESSION[
'assignedtouser'])) {
173 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'], 1);
175 $tmpassigneduserids = array();
178 foreach ($tmpassigneduserids as $key => $val) {
179 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
180 unset($tmpassigneduserids[$key]);
184 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
185 $donotclearsession = 1;
186 if ($action ==
'add') {
189 if ($action ==
'update') {
193 $listUserAssignedUpdated =
true;
196if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
197 $idtoremove =
GETPOST(
'removedassignedresource');
199 if (!empty($_SESSION[
'assignedtoresource'])) {
200 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'], 1);
202 $tmpassignedresourceids = array();
205 foreach ($tmpassignedresourceids as $key => $val) {
206 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
207 unset($tmpassignedresourceids[$key]);
211 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
212 $donotclearsessionresource = 1;
213 if ($action ==
'add') {
216 if ($action ==
'update') {
220 $listResourceAssignedUpdated =
true;
224if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
226 if (
GETPOST(
'assignedtouser') > 0) {
227 $assignedtouser = array();
228 if (!empty($_SESSION[
'assignedtouser'])) {
229 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
231 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id'=>
GETPOSTINT(
'assignedtouser'),
'transparency'=>
GETPOST(
'transparency'),
'mandatory'=>1);
232 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
234 $donotclearsession = 1;
235 if ($action ==
'add') {
238 if ($action ==
'update') {
242 $listUserAssignedUpdated =
true;
246if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
248 if (
GETPOST(
'assignedtoresource') > 0) {
249 $assignedtoresource = array();
250 if (!empty($_SESSION[
'assignedtoresource'])) {
251 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
253 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id'=>
GETPOSTINT(
'assignedtoresource'),
'transparency'=>
GETPOST(
'transparency'),
'mandatory'=>1);
254 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
256 $donotclearsession = 1;
257 if ($action ==
'add') {
260 if ($action ==
'update') {
264 $listResourceAssignedUpdated =
true;
268if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
269 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
271 $object->setProject(
GETPOST(
'projectid',
'int'));
275if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes') {
276 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
281 if (!empty($object->socpeopleassigned)) {
282 reset($object->socpeopleassigned);
283 $object->contact_id = key($object->socpeopleassigned);
285 $result = $object->createFromClone($user,
GETPOST(
'socid',
'int'));
287 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
298if (empty($reshook) && $action ==
'add') {
301 if (empty($backtopage)) {
303 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
305 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
309 if (!empty($socpeopleassigned[0])) {
310 $result = $contact->fetch($socpeopleassigned[0]);
314 header(
"Location: ".$backtopage);
318 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
324 $datep =
dol_mktime(
'00',
'00',
'00',
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
325 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
327 $datep =
dol_mktime(
GETPOST(
"aphour",
'int'),
GETPOST(
"apmin",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
328 $datef =
dol_mktime(
GETPOST(
"p2hour",
'int'),
GETPOST(
"p2min",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
332 if (!$datef && $percentage == 100) {
334 $donotclearsession = 1;
336 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
341 $donotclearsession = 1;
343 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
347 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
349 $donotclearsession = 1;
351 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
353 $object->type_code =
GETPOST(
'actioncode',
'aZ09');
358 $object->priority = GETPOSTISSET(
"priority") ?
GETPOST(
"priority",
"int") : 0;
359 $object->fulldayevent = ($fulldayevent ? 1 : 0);
360 $object->location =
GETPOST(
"location",
'alphanohtml');
361 $object->label =
GETPOST(
'label',
'alphanohtml');
363 if (
GETPOST(
"elementtype",
'alpha')) {
365 $modulecodetouseforpermissioncheck = $elProp[
'module'];
367 $hasPermissionOnLinkedObject = 0;
368 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
369 $hasPermissionOnLinkedObject = 1;
371 if ($hasPermissionOnLinkedObject) {
372 $object->fk_element =
GETPOST(
"fk_element",
'int');
373 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
378 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
379 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
381 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
382 $object->label = $langs->transnoentitiesnoconv(
"Action".$object->type_code).
"\n";
384 $cactioncomm->fetch($object->type_code);
385 $object->label = $cactioncomm->label;
389 $object->fk_project = GETPOSTISSET(
"projectid") ?
GETPOST(
"projectid",
'int') : 0;
391 $taskid =
GETPOST(
'taskid',
'int');
392 if (!empty($taskid)) {
393 $taskProject =
new Task($db);
394 if ($taskProject->fetch($taskid) > 0) {
395 $object->fk_project = $taskProject->fk_project;
398 $object->fk_element = $taskid;
399 $object->elementtype =
'task';
402 $object->datep = $datep;
403 $object->datef = $datef;
404 $object->percentage = $percentage;
405 $object->duree = (((int)
GETPOST(
'dureehour') * 60) + (
int)
GETPOST(
'dureemin')) * 60;
407 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
409 $listofuserid = array();
410 if (!empty($_SESSION[
'assignedtouser'])) {
411 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
414 if (!empty($_SESSION[
'assignedtoresource'])) {
415 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
419 foreach ($listofuserid as $key => $value) {
421 if ($value[
'id'] > 0) {
422 $object->userownerid = $value[
'id'];
424 $object->transparency = $transparency;
427 $object->userassigned[$value[
'id']] = array(
'id'=>$value[
'id'],
'transparency'=>$transparency);
435 $object->userdoneid =
GETPOST(
"doneby",
"int");
439 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
441 if (GETPOSTISSET(
"contactid")) {
442 $object->contact = $contact;
445 if (
GETPOST(
'socid',
'int') > 0) {
446 $object->socid =
GETPOST(
'socid',
'int');
447 $object->fetch_thirdparty();
449 $object->societe = $object->thirdparty;
453 if (empty($object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
455 $donotclearsession = 1;
457 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
459 if ($object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
461 $donotclearsession = 1;
463 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
468 $donotclearsession = 1;
470 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
473 foreach ($socpeopleassigned as $cid) {
474 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
476 if (!empty($object->socpeopleassigned)) {
477 reset($object->socpeopleassigned);
478 $object->contact_id = key($object->socpeopleassigned);
482 $ret = $extrafields->setOptionalsFromPost(
null, $object);
484 $error++; $donotclearsession = 1;
493 $selectedrecurrulefreq =
'no';
494 $selectedrecurrulebymonthday =
'';
495 $selectedrecurrulebyday =
'';
496 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
497 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' && GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
498 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' && GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
503 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) {
504 $selectedrecurrulefreq = $reg1[1];
506 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) {
507 $selectedrecurrulebymonthday = $reg2[1];
509 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) {
510 $selectedrecurrulebyday = $reg3[1];
514 $eventisrecurring = 0;
515 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
516 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
517 $eventisrecurring = 1;
521 unset($object->recurid);
522 unset($object->recurrule);
523 unset($object->recurdateend);
527 $idaction = $object->create($user);
531 if (!$object->error) {
532 if (is_array($listofresourceid) && count($listofresourceid)) {
533 foreach ($listofresourceid as $resource_id => $val) {
534 $resource_type =
'dolresource';
539 $eventDateStart = $object->datep;
540 $eventDateEnd = $object->datef;
541 $isFullDayEvent = $object->fulldayevent;
542 if (empty($eventDateEnd)) {
543 if ($isFullDayEvent) {
545 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
546 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
550 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
551 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
552 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) .
"'";
553 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element) .
"'";
554 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
555 $sql .=
" AND er.busy = 1";
559 $sql .=
" (ac.datep <= '" . $db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) .
"'))";
561 if (!empty($eventDateEnd)) {
562 $sql .=
" OR (ac.datep <= '" . $db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) .
"'))";
566 $sql .=
"ac.datep >= '" . $db->idate($eventDateStart) .
"'";
567 if (!empty($eventDateEnd)) {
568 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) .
"')";
573 $resql = $db->query($sql);
576 $object->error = $db->lasterror();
577 $object->errors[] = $object->error;
579 if ($db->num_rows($resql) > 0) {
582 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
583 while ($obj = $db->fetch_object($resql)) {
584 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
586 $object->errors[] = $object->error;
595 $res = $object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
600 unset($_SESSION[
'assignedtoresource']);
605 $categories =
GETPOST(
'categories',
'array');
606 $object->setCategories($categories);
609 unset($_SESSION[
'assignedtouser']);
611 if ($user->id != $object->userownerid) {
612 $moreparam =
"filtert=-1";
616 if (!$error && $addreminder ==
'on') {
621 $actionCommReminder->dateremind = $dateremind;
622 $actionCommReminder->typeremind = $remindertype;
623 $actionCommReminder->offsetunit = $offsetunit;
624 $actionCommReminder->offsetvalue = $offsetvalue;
625 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
626 $actionCommReminder->fk_actioncomm = $object->id;
627 if ($remindertype ==
'email') {
628 $actionCommReminder->fk_email_template = $modelmail;
632 foreach ($object->userassigned as $userassigned) {
633 $actionCommReminder->fk_user = $userassigned[
'id'];
634 $res = $actionCommReminder->create($user);
639 $langs->load(
"errors");
640 $error = $langs->trans(
'ErrorReminderActionCommCreation');
643 $donotclearsession = 1;
654 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
674 $langs->load(
"errors");
675 $error = $langs->trans($object->error);
678 $donotclearsession = 1;
684 $donotclearsession = 1;
687 if (!$error && $eventisrecurring) {
691 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
693 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'), $firstdatearray[
'month'], $firstdatearray[
'first_day'], $firstdatearray[
'year'], $tzforfullday ? $tzforfullday :
'tzuserrel');
697 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
698 $firstday = $selectedrecurrulebymonthday;
699 $firstmonth =
GETPOST(
"apday") > $selectedrecurrulebymonthday ?
GETPOST(
"apmonth",
'int') + 1 :
GETPOST(
"apmonth",
'int');
700 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'), $firstmonth, $firstday,
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
707 $repeateventlimitdate =
dol_mktime(23, 59, 59, GETPOSTISSET(
"limitmonth") ?
GETPOST(
"limitmonth",
'int') : 1, GETPOSTISSET(
"limitday") ?
GETPOST(
"limitday",
'int') : 1, GETPOSTISSET(
"limityear") &&
GETPOST(
"limityear",
'int') < 2100 ?
GETPOST(
"limityear",
'int') : 2100, $tzforfullday ? $tzforfullday :
'tzuserrel');
712 while ($datep <= $repeateventlimitdate && !$error) {
713 $finalobject = clone $object;
716 $finalobject->datep = $datep;
717 $finalobject->datef = $datef;
719 $idaction = $finalobject->create($user);
722 if (!$finalobject->error) {
724 $categories =
GETPOST(
'categories',
'array');
725 $finalobject->setCategories($categories);
727 unset($_SESSION[
'assignedtouser']);
730 if ($user->id != $finalobject->userownerid) {
731 $moreparam =
"filtert=-1";
735 if ($addreminder ==
'on') {
740 $actionCommReminder->dateremind = $dateremind;
741 $actionCommReminder->typeremind = $remindertype;
742 $actionCommReminder->offsetunit = $offsetunit;
743 $actionCommReminder->offsetvalue = $offsetvalue;
744 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
745 $actionCommReminder->fk_actioncomm = $finalobject->id;
746 if ($remindertype ==
'email') {
747 $actionCommReminder->fk_email_template = $modelmail;
751 foreach ($finalobject->userassigned as $userassigned) {
752 $actionCommReminder->fk_user = $userassigned[
'id'];
753 $res = $actionCommReminder->create($user);
758 $langs->load(
"errors");
759 $error = $langs->trans(
'ErrorReminderActionCommCreation');
762 $donotclearsession = 1;
773 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
783 $langs->load(
"errors");
784 $error = $langs->trans($finalobject->error);
787 $donotclearsession = 1;
793 $donotclearsession = 1;
797 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
808 if (!empty($backtopage) && !$error) {
809 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
810 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
811 } elseif ($idaction) {
812 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
814 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
823if (empty($reshook) && $action ==
'update') {
824 if (empty($cancel)) {
825 $fulldayevent =
GETPOST(
'fullday');
826 $aphour =
GETPOST(
'aphour',
'int');
827 $apmin =
GETPOST(
'apmin',
'int');
828 $p2hour =
GETPOST(
'p2hour',
'int');
829 $p2min =
GETPOST(
'p2min',
'int');
830 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
847 $object->fetch_optionals();
848 $object->fetch_userassigned();
849 $object->oldcopy =
dol_clone($object, 2);
855 $datep =
dol_mktime(
'00',
'00',
'00',
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
856 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
858 $datep =
dol_mktime(
GETPOST(
"aphour",
'int'),
GETPOST(
"apmin",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
859 $datef =
dol_mktime(
GETPOST(
"p2hour",
'int'),
GETPOST(
"p2min",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
862 if ($object->elementtype ==
'ticket') {
864 if ($object->code ==
'TICKET_MSG') {
865 $object->code =
'TICKET_MSG_PRIVATE';
867 if ($object->code ==
'TICKET_MSG_SENTBYMAIL') {
868 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
871 if ($object->code ==
'TICKET_MSG_PRIVATE') {
872 $object->code =
'TICKET_MSG';
874 if ($object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
875 $object->code =
'TICKET_MSG_SENTBYMAIL';
881 $object->type_code =
GETPOST(
"actioncode",
'aZ09');
884 $object->label =
GETPOST(
"label",
"alphanohtml");
885 $object->datep = $datep;
886 $object->datef = $datef;
887 $object->percentage = $percentage;
888 $object->priority =
GETPOST(
"priority",
"int");
889 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
890 $object->location =
GETPOST(
'location',
"alphanohtml");
891 $object->socid =
GETPOST(
"socid",
"int");
892 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
893 $object->socpeopleassigned = array();
894 foreach ($socpeopleassigned as $cid) {
895 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
897 $object->contact_id =
GETPOST(
"contactid",
'int');
898 if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
899 reset($object->socpeopleassigned);
900 $object->contact_id = key($object->socpeopleassigned);
902 $object->fk_project =
GETPOST(
"projectid",
'int');
903 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
905 if (
GETPOST(
"elementtype",
'alpha')) {
907 $modulecodetouseforpermissioncheck = $elProp[
'module'];
909 $hasPermissionOnLinkedObject = 0;
910 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
911 $hasPermissionOnLinkedObject = 1;
913 if ($hasPermissionOnLinkedObject) {
914 $object->fk_element =
GETPOST(
"fk_element",
'int');
915 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
919 if (!$datef && $percentage == 100) {
921 $donotclearsession = 1;
922 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), $object->errors,
'errors');
926 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
929 $listofuserid = array();
930 if (!empty($_SESSION[
'assignedtouser'])) {
932 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
933 foreach ($tmplist1 as $key => $val) {
934 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
935 $listofuserid[$val[
'id']] = $val;
939 $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
940 if ($assignedtouser) {
941 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>($user->id == $assignedtouser ? $transparency :
''));
944 $object->userassigned = array();
945 $object->userownerid = 0;
947 foreach ($listofuserid as $key => $val) {
949 $object->userownerid = $val[
'id'];
951 $object->userassigned[$val[
'id']] = array(
'id'=>$val[
'id'],
'mandatory'=>0,
'transparency'=>($user->id == $val[
'id'] ? $transparency :
''));
955 $object->transparency = $transparency;
960 $object->userdoneid =
GETPOST(
"doneby",
"int");
965 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
967 $donotclearsession = 1;
969 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
971 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
973 if (empty($object->userownerid)) {
975 $donotclearsession = 1;
977 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
981 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
988 if (
getDolGlobalString(
'RESOURCE_USED_IN_EVENT_CHECK') && $object->element ==
'action') {
989 $eventDateStart = $object->datep;
990 $eventDateEnd = $object->datef;
992 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
993 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
994 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
995 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
996 $sql .=
" WHERE ac.id <> ".((int) $object->id);
997 $sql .=
" AND er.resource_id IN (";
998 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
999 $sql .=
" WHERE element_id = ".((int) $object->id);
1000 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
1001 $sql .=
" AND busy = 1";
1003 $sql .=
" AND er.busy = 1";
1007 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1009 if (!empty($eventDateEnd)) {
1010 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1014 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1015 if (!empty($eventDateEnd)) {
1016 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1021 $resql = $db->query($sql);
1024 $object->error = $db->lasterror();
1025 $object->errors[] = $object->error;
1027 if ($db->num_rows($resql) > 0) {
1030 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1031 while ($obj = $db->fetch_object($resql)) {
1032 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1034 $object->errors[] = $object->error;
1048 $result = $object->update($user);
1052 $categories =
GETPOST(
'categories',
'array');
1053 $object->setCategories($categories);
1055 $object->loadReminders($remindertype, 0,
false);
1058 if (!empty($object->reminders)) {
1059 foreach ($object->reminders as $reminder) {
1060 if ($reminder->status < 1) {
1061 $reminder->delete($user);
1064 $object->reminders = array();
1068 if ($addreminder ==
'on') {
1073 $actionCommReminder->dateremind = $dateremind;
1074 $actionCommReminder->typeremind = $remindertype;
1075 $actionCommReminder->offsetunit = $offsetunit;
1076 $actionCommReminder->offsetvalue = $offsetvalue;
1077 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1078 $actionCommReminder->fk_actioncomm = $object->id;
1079 if ($remindertype ==
'email') {
1080 $actionCommReminder->fk_email_template = $modelmail;
1084 foreach ($object->userassigned as $userassigned) {
1085 $actionCommReminder->fk_user = $userassigned[
'id'];
1086 $res = $actionCommReminder->create($user);
1090 $langs->load(
"errors");
1091 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1094 $donotclearsession = 1;
1100 unset($_SESSION[
'assignedtouser']);
1101 unset($_SESSION[
'assignedtoresource']);
1116 if (!empty($backtopage)) {
1117 unset($_SESSION[
'assignedtouser']);
1118 header(
"Location: ".$backtopage);
1125if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1126 $object->fetch($id);
1127 $object->fetch_optionals();
1128 $object->fetch_userassigned();
1129 $object->oldcopy =
dol_clone($object, 2);
1131 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1132 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1133 $result = $object->delete();
1136 header(
"Location: index.php");
1148if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1154 $newdate =
GETPOST(
'newdate',
'alpha');
1155 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1156 header(
"Location: ".$backtopage,
true, 307);
1160 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
1163 if ($datep != $object->datep) {
1164 if (!empty($object->datef)) {
1165 $object->datef += $datep - $object->datep;
1167 $object->datep = $datep;
1171 if (
getDolGlobalString(
'RESOURCE_USED_IN_EVENT_CHECK') && $object->element ==
'action') {
1172 $eventDateStart = $object->datep;
1173 $eventDateEnd = $object->datef;
1175 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1176 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1177 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1178 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
1179 $sql .=
" WHERE ac.id <> ".((int) $object->id);
1180 $sql .=
" AND er.resource_id IN (";
1181 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1182 $sql .=
" WHERE element_id = ".((int) $object->id);
1183 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
1184 $sql .=
" AND busy = 1";
1186 $sql .=
" AND er.busy = 1";
1190 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1192 if (!empty($eventDateEnd)) {
1193 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1197 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1198 if (!empty($eventDateEnd)) {
1199 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1204 $resql = $db->query($sql);
1207 $object->error = $db->lasterror();
1208 $object->errors[] = $object->error;
1210 if ($db->num_rows($resql) > 0) {
1213 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1214 while ($obj = $db->fetch_object($resql)) {
1215 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1217 $object->errors[] = $object->error;
1230 $result = $object->update($user);
1240 if (!empty($backtopage)) {
1241 header(
"Location: ".$backtopage,
true, 307);
1250$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1251if (empty($reshook)) {
1252 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1260$form =
new Form($db);
1263$arrayrecurrulefreq = array(
1264 'no'=>$langs->trans(
"OnceOnly"),
1265 'MONTHLY'=>$langs->trans(
"EveryMonth"),
1266 'WEEKLY'=>$langs->trans(
"EveryWeek")
1271$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1272llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1274if ($action ==
'create') {
1277 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1278 if (!empty($socpeopleassigned[0])) {
1279 $result = $contact->fetch($socpeopleassigned[0]);
1287 if (!empty($conf->use_javascript_ajax)) {
1288 print
"\n".
'<script type="text/javascript">';
1289 print
'$(document).ready(function () {
1290 function setdatefields()
1292 if ($("#fullday:checked").val() == null) {
1293 $(".fulldaystarthour").removeAttr("disabled");
1294 $(".fulldaystartmin").removeAttr("disabled");
1295 $(".fulldayendhour").removeAttr("disabled");
1296 $(".fulldayendmin").removeAttr("disabled");
1297 $("#p2").removeAttr("disabled");
1299 $(".fulldaystarthour").prop("disabled", true).val("00");
1300 $(".fulldaystartmin").prop("disabled", true).val("00");
1301 $(".fulldayendhour").prop("disabled", true).val("23");
1302 $(".fulldayendmin").prop("disabled", true).val("59");
1303 $("#p2").removeAttr("disabled");
1306 $("#fullday").change(function() {
1307 console.log("setdatefields");
1311 $("#selectcomplete").change(function() {
1312 console.log("we change the complete status - set the doneby");
1313 if ($("#selectcomplete").val() == 100) {
1314 if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).
'\');
1316 if ($(
"#selectcomplete").val() == 0) {
1317 $(
"#doneby").val(-1);
1321 $(
"#actioncode").change(
function() {
1322 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
1323 else $("#dateend").removeClass("fieldrequired");
1325 $("#aphour,#apmin").change(function() {
1326 if ($("#actioncode").val() == \'AC_RDV\') {
1327 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1328 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1329 $("#p2min").val($("#apmin").val());
1330 $("#p2day").val($("#apday").val());
1331 $("#p2month").val($("#apmonth").val());
1332 $("#p2year").val($("#apyear").val());
1333 $("#p2").val($("#ap").val());
1336 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1337 else $("#dateend").removeClass("fieldrequired");
1340 print
'</script>'.
"\n";
1343 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1344 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1345 print
'<input type="hidden" name="action" value="add">';
1346 print
'<input type="hidden" name="donotclearsession" value="1">';
1347 print
'<input type="hidden" name="page_y" value="">';
1349 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1352 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1355 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1356 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1363 print
'<table class="border centpercent">';
1367 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1369 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1370 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : ($object->type_code ? $object->type_code : $default);
1371 print
$formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1376 print
'<tr><td'.(!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ?
' class="fieldrequired titlefieldcreate"' :
'').
'>'.$langs->trans(
"Label").
'</td><td><input type="text" id="label" name="label" class="soixantepercent" value="'.
GETPOST(
'label').
'"></td></tr>';
1379 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>';
1382 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1383 if ($userepeatevent) {
1386 print
' <div class="opacitymedium inline-block">';
1387 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1388 print
'<input type="hidden" name="recurid" value="'.(empty($object->recurid) ?
'' : $object->recurid).
'">';
1390 $selectedrecurrulefreq =
'no';
1391 $selectedrecurrulebymonthday =
'';
1392 $selectedrecurrulebyday =
'';
1393 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1394 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1395 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1399 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1400 $selectedrecurrulefreq = $reg[1];
1402 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) {
1403 $selectedrecurrulebymonthday = $reg[1];
1405 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1406 $selectedrecurrulebyday = $reg[1];
1409 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1415 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1416 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1419 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1420 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1423 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1424 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1425 print $langs->trans(
"Until").
" ";
1426 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1429 print
'<script type="text/javascript">
1430 jQuery(document).ready(function() {
1431 function init_repeat()
1433 console.log("recurrule: " + "'.$object->recurrule.
'");
1434 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1435 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1436 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1437 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1438 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1440 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1441 jQuery(".repeateventlimitdate").css("display", "inline-block");
1442 jQuery(".repeateventBYDAY").hide();
1444 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1446 jQuery(".repeateventBYMONTHDAY").hide();
1447 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1448 jQuery(".repeateventlimitdate").css("display", "inline-block");
1452 jQuery(".repeateventBYMONTHDAY").hide();
1453 jQuery(".repeateventBYDAY").hide();
1454 jQuery(".repeateventlimitdate").hide();
1458 jQuery("#recurrulefreq").change(function() {
1469 $datep = ($datep ? $datep : (is_null($object->datep) ?
'' : $object->datep));
1470 if (
GETPOST(
'datep',
'int', 1)) {
1473 $datef = ($datef ? $datef : $object->datef);
1474 if (
GETPOST(
'datef',
'int', 1)) {
1477 if (empty($datef) && !empty($datep)) {
1484 print
'<tr><td class="nowrap">';
1487 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1489 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1491 print
' <span class="hideonsmartphone"> - </span> ';
1493 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1495 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1499 print
'<tr><td class=""> </td><td></td></tr>';
1502 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1503 $listofuserid = array();
1504 $listofcontactid = array();
1505 $listofotherid = array();
1507 if (empty($donotclearsession)) {
1508 $assignedtouser =
GETPOST(
"assignedtouser") ?
GETPOST(
"assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1509 if ($assignedtouser) {
1510 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0);
1513 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1514 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1516 if (!empty($_SESSION[
'assignedtouser'])) {
1517 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1519 $firstelem = reset($listofuserid);
1520 if (isset($listofuserid[$firstelem[
'id']])) {
1521 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1524 print
'<div class="assignedtouser">';
1525 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1531 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1532 print $form->select_dolusers(GETPOSTISSET(
"doneby") ?
GETPOST(
"doneby",
'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0),
'doneby', 1);
1538 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>';
1541 if (isModEnabled(
'categorie')) {
1543 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1544 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1545 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1549 if (isModEnabled(
'resource')) {
1551 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1553 $listofresourceid = array();
1554 if (empty($donotclearsession)) {
1555 $assignedtoresource =
GETPOST(
"assignedtoresource");
1556 if ($assignedtoresource) {
1557 $listofresourceid[$assignedtoresource] = array(
'id'=>$assignedtoresource,
'mandatory'=>0);
1559 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1561 if (!empty($_SESSION[
'assignedtoresource'])) {
1562 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1564 $firstelem = reset($listofresourceid);
1565 if (isset($listofresourceid[$firstelem[
'id']])) {
1566 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1569 print
'<div class="assignedtoresource">';
1570 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1576 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1578 $percent = $complete !==
'' ? $complete : -1;
1579 if (GETPOSTISSET(
'status')) {
1581 } elseif (GETPOSTISSET(
'percentage')) {
1582 $percent =
GETPOST(
'percentage',
'int');
1584 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1586 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1590 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1596 print
'<br><hr><br>';
1599 print
'<table class="border centpercent">';
1601 if (isModEnabled(
"societe")) {
1603 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1604 if (
GETPOST(
'socid',
'int') > 0) {
1606 $societe->fetch(
GETPOST(
'socid',
'int'));
1607 print $societe->getNomUrl(1);
1608 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOST(
'socid',
'int').
'">';
1611 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1613 if (!empty($user->socid)) {
1614 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1616 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1622 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1623 $preselectedids =
GETPOST(
'socpeopleassigned',
'array');
1624 if (
GETPOST(
'contactid',
'int')) {
1625 $preselectedids[
GETPOST(
'contactid',
'int')] =
GETPOST(
'contactid',
'int');
1627 if ($origin==
'contact') {
1628 $preselectedids[
GETPOST(
'originid',
'int')] =
GETPOST(
'originid',
'int');
1632 $select_contact_default = 0;
1634 $select_contact_default = -1;
1636 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1637 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', false, 0, array(), false,
'multiple',
'contactid');
1642 if (isModEnabled(
'project')) {
1643 $langs->load(
"projects");
1645 $projectid =
GETPOST(
'projectid',
'int');
1647 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1648 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1649 print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1651 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1652 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1653 $urloption =
'?action=create&donotclearsession=1';
1657 print
"\n".
'<script type="text/javascript">';
1658 print
'$(document).ready(function () {
1659 $("#projectid").change(function () {
1660 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1661 console.log("Call url to get new list of tasks: "+url);
1662 $.get(url, function(data) {
1664 if (data) $("#taskid").html(data).select2();
1668 print
'</script>'.
"\n";
1673 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1674 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1675 $projectsListId =
false;
1676 if (!empty($projectid)) {
1677 $projectsListId = $projectid;
1680 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOST(
"projecttaskid",
'int') : (GETPOSTISSET(
"taskid") ?
GETPOST(
"taskid",
'int') :
'');
1682 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1687 if (!empty($origin) && !empty($originid)) {
1688 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1690 $hasPermissionOnLinkedObject = 0;
1693 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1694 $hasPermissionOnLinkedObject = 1;
1698 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1700 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1701 print
'<td colspan="3">';
1702 if ($hasPermissionOnLinkedObject) {
1704 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1705 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1706 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1707 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1709 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1717 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1718 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOST(
'priority',
'int') : ($object->priority ? $object->priority :
'')).
'" size="5">';
1723 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1724 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1725 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') : $object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1726 $doleditor->Create();
1730 $parameters = array();
1731 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1732 print $hookmanager->resPrint;
1733 if (empty($reshook)) {
1734 print $object->showOptionals($extrafields,
'create', $parameters);
1744 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1746 print
'<div class="reminderparameters" style="display: none;">';
1748 print
'<table class="border centpercent">';
1751 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1752 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOST(
'offsetvalue',
'int') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1753 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1757 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1758 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1763 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1764 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1771 print
"\n".
'<script type="text/javascript">';
1772 print
'$(document).ready(function () {
1773 $("#addreminder").click(function(){
1774 console.log("Click on addreminder");
1776 $(".reminderparameters").show();
1778 $(".reminderparameters").hide();
1780 $("#selectremindertype").select2("destroy");
1781 $("#selectremindertype").select2();
1782 $("#select_offsetunittype_duration").select2("destroy");
1783 $("#select_offsetunittype_duration").select2();
1784 selectremindertype();
1787 $("#selectremindertype").change(function(){
1788 selectremindertype();
1791 function selectremindertype() {
1792 console.log("Call selectremindertype");
1793 var selected_option = $("#selectremindertype option:selected").val();
1794 if(selected_option == "email") {
1795 $("#select_actioncommsendmodel_mail").closest("tr").show();
1797 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1802 print
'</script>'.
"\n";
1807 print $form->buttonsSaveCancel(
"Add");
1814 $result1 = $object->fetch($id);
1815 if ($result1 <= 0) {
1816 $langs->load(
"errors");
1817 print $langs->trans(
"ErrorRecordNotFound");
1823 $result2 = $object->fetch_thirdparty();
1824 $result2 = $object->fetch_projet();
1825 $result3 = $object->fetch_contact();
1826 $result4 = $object->fetch_userassigned();
1827 $result5 = $object->fetch_optionals();
1829 if ($listUserAssignedUpdated || $donotclearsession) {
1830 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
1832 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
1833 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
1836 $object->label =
GETPOST(
"label",
"alphanohtml");
1837 $object->datep = $datep;
1838 $object->datef = $datef;
1839 $object->percentage = $percentage;
1840 $object->priority =
GETPOST(
"priority",
"alphanohtml");
1841 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
1842 $object->location =
GETPOST(
'location',
"alphanohtml");
1843 $object->socid =
GETPOST(
"socid",
"int");
1844 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1845 foreach ($socpeopleassigned as $tmpid) {
1846 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1848 $object->contact_id =
GETPOST(
"contactid",
'int');
1849 $object->fk_project =
GETPOST(
"projectid",
'int');
1851 $object->note_private =
GETPOST(
"note",
'restricthtml');
1854 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1859 if ($object->authorid > 0) {
1860 $tmpuser =
new User($db);
1861 $res = $tmpuser->fetch($object->authorid);
1862 $object->author = $tmpuser;
1864 if ($object->usermodid > 0) {
1865 $tmpuser =
new User($db);
1866 $res = $tmpuser->fetch($object->usermodid);
1867 $object->usermod = $tmpuser;
1878 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1882 if ($action ==
'delete') {
1883 print $form->formconfirm(
"card.php?id=".urlencode($id), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1886 if ($action ==
'edit') {
1887 if (!empty($conf->use_javascript_ajax)) {
1888 print
"\n".
'<script type="text/javascript">';
1889 print
'$(document).ready(function () {
1890 function setdatefields()
1892 if ($("#fullday:checked").val() == null) {
1893 $(".fulldaystarthour").removeAttr("disabled");
1894 $(".fulldaystartmin").removeAttr("disabled");
1895 $(".fulldayendhour").removeAttr("disabled");
1896 $(".fulldayendmin").removeAttr("disabled");
1898 $(".fulldaystarthour").prop("disabled", true).val("00");
1899 $(".fulldaystartmin").prop("disabled", true).val("00");
1900 $(".fulldayendhour").prop("disabled", true).val("23");
1901 $(".fulldayendmin").prop("disabled", true).val("59");
1905 $("#fullday").change(function() {
1908 $("#actioncode").change(function() {
1909 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1910 else $("#dateend").removeClass("fieldrequired");
1913 print
'</script>'.
"\n";
1916 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1917 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1918 print
'<input type="hidden" name="action" value="update">';
1919 print
'<input type="hidden" name="id" value="'.$id.
'">';
1920 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1921 print
'<input type="hidden" name="page_y" value="">';
1923 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1925 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && ! preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code)) {
1926 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1931 print
'<table class="border tableforfield" width="100%">';
1934 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.$object->id.
'</td></tr>';
1937 if (
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && $object->elementtype !=
"ticket") {
1938 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1939 if ($object->type_code !=
'AC_OTH_AUTO') {
1940 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1941 print
$formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') : $object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1943 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1944 print $object->getTypePicto();
1945 print $langs->trans(
"Action".$object->type_code);
1951 if ($object->elementtype ==
'ticket') {
1952 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
1953 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1954 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code) ?
' checked' :
'').
'></td></tr>';
1958 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>';
1961 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' :
'').
'>';
1962 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2025 print
'<tr><td class="nowrap">';
2030 print
'</td><td td colspan="3">';
2033 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 0,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2034 } elseif (
GETPOST(
"afaire") == 2) {
2035 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2037 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2039 print
' <span class="hideonsmartphone"> - </span> ';
2041 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2042 } elseif (
GETPOST(
"afaire") == 2) {
2043 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2045 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2049 print
'<tr><td class=""> </td><td></td></tr>';
2052 $listofuserid = array();
2053 if (empty($donotclearsession)) {
2054 if ($object->userownerid > 0) {
2055 $listofuserid[$object->userownerid] = array(
2056 'id'=>$object->userownerid,
2059 'transparency'=>$object->transparency,
2060 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2061 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2064 if (!empty($object->userassigned)) {
2066 $tmplist1 = $object->userassigned;
2067 foreach ($tmplist1 as $key => $val) {
2068 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2069 $listofuserid[$val[
'id']] = $val;
2073 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2075 if (!empty($_SESSION[
'assignedtouser'])) {
2076 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2079 $listofcontactid = $object->socpeopleassigned;
2080 $listofotherid = $object->otherassigned;
2082 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
2083 print
'<div class="assignedtouser">';
2084 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
2096 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td colspan="3">';
2097 print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1,
'doneby', 1);
2103 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
2107 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
2108 $percent = GETPOSTISSET(
"percentage") ?
GETPOST(
"percentage",
"int") : $object->percentage;
2109 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
2113 if (isModEnabled(
'categorie')) {
2114 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2115 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
2117 $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
2118 $arrayselected = array();
2119 foreach ($cats as $cat) {
2120 $arrayselected[] = $cat->id;
2122 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2129 print
'<br><hr><br>';
2132 print
'<table class="border tableforfield centpercent">';
2134 if (isModEnabled(
"societe")) {
2136 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2140 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2143 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth200');
2148 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2149 print
'<div class="maxwidth200onsmartphone">';
2151 $searchSocid = ($object->socid > 0) ? $object->socid : (
getDolGlobalString(
'MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT') ? 0 : -1);
2153 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2154 print $form->selectcontacts(
2156 array_keys($object->socpeopleassigned),
2157 'socpeopleassigned[]',
2162 'minwidth300 widthcentpercentminusx',
2177 if (isModEnabled(
'project')) {
2178 $langs->load(
"projects");
2180 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2181 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2182 $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');
2183 if ($numprojet == 0) {
2184 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>';
2191 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2192 print
'<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
2197 if (!empty($object->fk_element) && !empty($object->elementtype)) {
2198 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2200 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2202 if ($object->elementtype ==
'task' && isModEnabled(
'project')) {
2203 print
'<td id="project-task-input-container" >';
2205 $urloption =
'?action=create&donotclearsession=1';
2206 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2209 print
"\n".
'<script type="text/javascript" >';
2210 print
'$(document).ready(function () {
2211 $("#projectid").change(function () {
2212 var url = "'.$url.
'&projectid="+$("#projectid").val();
2213 $.get(url, function(data) {
2214 console.log($( data ).find("#fk_element").html());
2215 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2219 print
'</script>'.
"\n";
2221 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
2222 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2228 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2229 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2237 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2239 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2240 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2241 $doleditor->Create();
2245 $parameters = array();
2246 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2247 print $hookmanager->resPrint;
2248 if (empty($reshook)) {
2249 print $object->showOptionals($extrafields,
'edit', $parameters);
2256 $filteruserid = $user->id;
2257 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2260 $object->loadReminders(
'', $filteruserid,
false);
2264 if (count($object->reminders) > 0) {
2265 $checked =
'checked';
2266 $keys = array_keys($object->reminders);
2267 $firstreminderId = array_shift($keys);
2269 $actionCommReminder = $object->reminders[$firstreminderId];
2273 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2274 $actionCommReminder->offsetunit =
'i';
2275 $actionCommReminder->typeremind =
'email';
2278 if ($object->datep <
dol_now()) {
2282 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>';
2284 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2288 print
'<table class="border centpercent">';
2291 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2292 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2293 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2297 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2298 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2302 if ($actionCommReminder->typeremind ==
'browser') {
2303 $hide =
'style="display:none;"';
2308 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2309 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2315 print
"\n".
'<script type="text/javascript">';
2316 print
'$(document).ready(function () {
2317 $("#addreminder").click(function(){
2319 $(".reminderparameters").show();
2321 $(".reminderparameters").hide();
2325 $("#selectremindertype").change(function(){
2326 var selected_option = $("#selectremindertype option:selected").val();
2327 if(selected_option == "email") {
2328 $("#select_actioncommsendmodel_mail").closest("tr").show();
2330 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2335 print
'</script>'.
"\n";
2342 print $form->buttonsSaveCancel();
2351 if ($action ==
'clone') {
2352 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', array(),
'yes', 1);
2356 $parameters = array();
2357 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2358 if (empty($reshook)) {
2359 $formconfirm.=$hookmanager->resPrint;
2360 } elseif ($reshook > 0) {
2361 $formconfirm=$hookmanager->resPrint;
2369 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2370 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
2371 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
2372 $linkback .=
'</a>';
2373 $linkback .=
'</li>';
2374 $linkback .=
'<li class="noborder litext">';
2375 $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').
'">';
2376 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
2377 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
2378 $linkback .=
'</a>';
2379 $linkback .=
'</li>';
2380 $linkback .=
'<li class="noborder litext">';
2381 $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').
'">';
2382 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
2383 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
2384 $linkback .=
'</a>';
2385 $linkback .=
'</li>';
2386 $linkback .=
'<li class="noborder litext">';
2387 $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').
'">';
2388 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
2389 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
2390 $linkback .=
'</a>';
2391 $linkback .=
'</li>';
2392 $linkback .=
'<li class="noborder litext">';
2393 $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').
'">';
2394 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
2395 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
2396 $linkback .=
'</a>';
2399 $parameters = array();
2400 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
2401 if (empty($reshook)) {
2402 $linkback .= $hookmanager->resPrint;
2403 } elseif ($reshook > 1) {
2404 $linkback = $hookmanager->resPrint;
2409 $morehtmlref =
'<div class="refidno">';
2413 if (isModEnabled(
'project')) {
2414 $langs->load(
"projects");
2416 if ($usercancreate) {
2417 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2418 if ($action !=
'classify') {
2419 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2421 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2423 if (!empty($object->fk_project)) {
2425 $proj->fetch($object->fk_project);
2426 $morehtmlref .= $proj->getNomUrl(1);
2428 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2433 $morehtmlref .=
'</div>';
2436 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2438 print
'<div class="fichecenter">';
2439 print
'<div class="fichehalfleft">';
2441 print
'<div class="underbanner clearboth"></div>';
2444 print
'<table class="border tableforfield" width="100%">';
2448 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2449 print $object->getTypePicto();
2450 print $langs->trans(
"Action".$object->type_code);
2455 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2458 if ($object->recurid) {
2459 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag($object->recurid).
'</td></tr>';
2468 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2473 if (empty($object->fulldayevent)) {
2477 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2479 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2486 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2487 if (empty($object->fulldayevent)) {
2491 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2493 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2500 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
2504 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2505 $listofuserid = array();
2506 if (empty($donotclearsession)) {
2507 if ($object->userownerid > 0) {
2508 $listofuserid[$object->userownerid] = array(
2509 'id'=>$object->userownerid,
2510 'transparency'=>$object->transparency,
2511 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2512 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2515 if (!empty($object->userassigned)) {
2517 $tmplist1 = $object->userassigned;
2518 foreach ($tmplist1 as $key => $val) {
2519 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2520 $listofuserid[$val[
'id']] = $val;
2524 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2526 if (!empty($_SESSION[
'assignedtouser'])) {
2527 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2531 $listofcontactid = array();
2532 $listofotherid = array();
2533 print
'<div class="assignedtouser">';
2534 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2544 print
' </td></tr>';
2548 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
2549 if ($object->userdoneid > 0) {
2550 $tmpuser =
new User($db);
2551 $tmpuser->fetch($object->userdoneid);
2552 print $tmpuser->getNomUrl(1);
2558 if (isModEnabled(
'categorie')) {
2559 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2560 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2568 print
'<div class="fichehalfright">';
2570 print
'<div class="underbanner clearboth"></div>';
2571 print
'<table class="border tableforfield centpercent">';
2573 if (isModEnabled(
"societe")) {
2575 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2576 print
'<td>'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2577 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL') {
2578 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2579 print
"<br>".dol_print_phone($object->thirdparty->phone);
2585 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2588 if (!empty($object->socpeopleassigned)) {
2589 foreach ($object->socpeopleassigned as $cid => $Tab) {
2591 $result = $contact->fetch($cid);
2598 print $contact->getNomUrl(1);
2599 if ($object->type_code ==
'AC_TEL') {
2600 if (!empty($contact->phone_pro)) {
2601 print
'('.dol_print_phone($contact->phone_pro).
')';
2604 print
'<div class="paddingright"></div>';
2608 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2615 print
'<tr><td class="nowrap" class="titlefield">' . $langs->trans(
"Priority") .
'</td><td>';
2616 print($object->priority ? $object->priority :
'');
2622 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project'))) {
2623 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2624 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2628 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2636 if (!empty($object->email_msgid)) {
2637 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2638 print
'<td>'.dol_escape_htmltag($object->email_subject).
'</td></tr>';
2639 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2640 print
'<td>'.dol_escape_htmltag($object->email_from).
'</td></tr>';
2641 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2642 print
'<td>'.dol_escape_htmltag($object->email_to).
'</td></tr>';
2643 if (!empty($object->email_tocc)) {
2644 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2645 print
'<td>'.dol_escape_htmltag($object->email_tocc).
'</td></tr>';
2650 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2655 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2659 $filteruserid = $user->id;
2660 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2663 $object->loadReminders(
'', $filteruserid,
false);
2665 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2667 if (count($object->reminders) > 0) {
2668 $tmpuserstatic =
new User($db);
2670 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2671 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2672 if ($actioncommreminder->fk_user > 0) {
2673 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2674 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2676 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2678 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2679 print
' - <span class="opacitymedium">';
2680 print $langs->trans(
"NotSent");
2682 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2683 print
' - <span class="opacitymedium">';
2684 print $langs->trans(
"Done");
2686 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2687 print
' - <span class="opacitymedium">';
2688 print $form->textwithpicto($langs->trans(
"Error"), $actioncommreminder->lasterror);
2702 print
'<div class="clearboth"></div>';
2711 print
'<div class="tabsAction">';
2713 $parameters = array();
2714 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2715 if (empty($reshook)) {
2716 if ($action !=
'edit') {
2717 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2718 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2719 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2721 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2724 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2725 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2726 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>';
2728 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2731 if ($user->hasRight(
'agenda',
'allactions',
'delete') ||
2732 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2733 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2735 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2742 if ($action !=
'edit') {
2744 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2745 print
'<a name="builddoc"></a>';
2751 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2752 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2754 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2755 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2758 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2760 print
'</div><div class="fichehalfright">';
2763 print
'</div></div>';
actions_prepare_head($object)
Prepare array with list of tabs.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getElementProperties($element_type)
Get an array with properties of an element.
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_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 editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.