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 foreach ($listofuserid as $key => $value) {
416 if ($value[
'id'] > 0) {
417 $object->userownerid = $value[
'id'];
419 $object->transparency = $transparency;
422 $object->userassigned[$value[
'id']] = array(
'id'=>$value[
'id'],
'transparency'=>$transparency);
430 $object->userdoneid =
GETPOST(
"doneby",
"int");
434 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
436 if (GETPOSTISSET(
"contactid")) {
437 $object->contact = $contact;
440 if (
GETPOST(
'socid',
'int') > 0) {
441 $object->socid =
GETPOST(
'socid',
'int');
442 $object->fetch_thirdparty();
444 $object->societe = $object->thirdparty;
448 if (empty($object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
450 $donotclearsession = 1;
452 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
454 if ($object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
456 $donotclearsession = 1;
458 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
463 $donotclearsession = 1;
465 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
468 foreach ($socpeopleassigned as $cid) {
469 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
471 if (!empty($object->socpeopleassigned)) {
472 reset($object->socpeopleassigned);
473 $object->contact_id = key($object->socpeopleassigned);
477 $ret = $extrafields->setOptionalsFromPost(
null, $object);
479 $error++; $donotclearsession = 1;
488 $selectedrecurrulefreq =
'no';
489 $selectedrecurrulebymonthday =
'';
490 $selectedrecurrulebyday =
'';
491 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
492 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' && GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
493 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' && GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
498 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) {
499 $selectedrecurrulefreq = $reg1[1];
501 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) {
502 $selectedrecurrulebymonthday = $reg2[1];
504 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) {
505 $selectedrecurrulebyday = $reg3[1];
509 $eventisrecurring = 0;
510 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
511 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
512 $eventisrecurring = 1;
516 unset($object->recurid);
517 unset($object->recurrule);
518 unset($object->recurdateend);
522 $idaction = $object->create($user);
525 if (!$object->error) {
527 $categories =
GETPOST(
'categories',
'array');
528 $object->setCategories($categories);
530 unset($_SESSION[
'assignedtouser']);
533 if ($user->id != $object->userownerid) {
534 $moreparam =
"filtert=-1";
538 if ($addreminder ==
'on') {
543 $actionCommReminder->dateremind = $dateremind;
544 $actionCommReminder->typeremind = $remindertype;
545 $actionCommReminder->offsetunit = $offsetunit;
546 $actionCommReminder->offsetvalue = $offsetvalue;
547 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
548 $actionCommReminder->fk_actioncomm = $object->id;
549 if ($remindertype ==
'email') {
550 $actionCommReminder->fk_email_template = $modelmail;
554 foreach ($object->userassigned as $userassigned) {
555 $actionCommReminder->fk_user = $userassigned[
'id'];
556 $res = $actionCommReminder->create($user);
561 $langs->load(
"errors");
562 $error = $langs->trans(
'ErrorReminderActionCommCreation');
565 $donotclearsession = 1;
576 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
596 $langs->load(
"errors");
597 $error = $langs->trans($object->error);
600 $donotclearsession = 1;
606 $donotclearsession = 1;
609 if ($eventisrecurring) {
611 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
613 $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');
617 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
618 $firstday = $selectedrecurrulebymonthday;
619 $firstmonth =
GETPOST(
"apday") > $selectedrecurrulebymonthday ?
GETPOST(
"apmonth",
'int') + 1 :
GETPOST(
"apmonth",
'int');
620 $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');
627 $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');
632 while ($datep <= $repeateventlimitdate && !$error) {
633 $finalobject = clone $object;
636 $finalobject->datep = $datep;
637 $finalobject->datef = $datef;
639 $idaction = $finalobject->create($user);
642 if (!$finalobject->error) {
644 $categories =
GETPOST(
'categories',
'array');
645 $finalobject->setCategories($categories);
647 unset($_SESSION[
'assignedtouser']);
650 if ($user->id != $finalobject->userownerid) {
651 $moreparam =
"filtert=-1";
655 if ($addreminder ==
'on') {
660 $actionCommReminder->dateremind = $dateremind;
661 $actionCommReminder->typeremind = $remindertype;
662 $actionCommReminder->offsetunit = $offsetunit;
663 $actionCommReminder->offsetvalue = $offsetvalue;
664 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
665 $actionCommReminder->fk_actioncomm = $finalobject->id;
666 if ($remindertype ==
'email') {
667 $actionCommReminder->fk_email_template = $modelmail;
671 foreach ($finalobject->userassigned as $userassigned) {
672 $actionCommReminder->fk_user = $userassigned[
'id'];
673 $res = $actionCommReminder->create($user);
678 $langs->load(
"errors");
679 $error = $langs->trans(
'ErrorReminderActionCommCreation');
682 $donotclearsession = 1;
693 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
703 $langs->load(
"errors");
704 $error = $langs->trans($finalobject->error);
707 $donotclearsession = 1;
713 $donotclearsession = 1;
717 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
728 if (!empty($backtopage) && !$error) {
729 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
730 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
731 } elseif ($idaction) {
732 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
734 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
743if (empty($reshook) && $action ==
'update') {
744 if (empty($cancel)) {
745 $fulldayevent =
GETPOST(
'fullday');
746 $aphour =
GETPOST(
'aphour',
'int');
747 $apmin =
GETPOST(
'apmin',
'int');
748 $p2hour =
GETPOST(
'p2hour',
'int');
749 $p2min =
GETPOST(
'p2min',
'int');
750 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
767 $object->fetch_optionals();
768 $object->fetch_userassigned();
769 $object->oldcopy =
dol_clone($object, 2);
775 $datep =
dol_mktime(
'00',
'00',
'00',
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
776 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
778 $datep =
dol_mktime(
GETPOST(
"aphour",
'int'),
GETPOST(
"apmin",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
779 $datef =
dol_mktime(
GETPOST(
"p2hour",
'int'),
GETPOST(
"p2min",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
782 if ($object->elementtype ==
'ticket') {
784 if ($object->code ==
'TICKET_MSG') {
785 $object->code =
'TICKET_MSG_PRIVATE';
787 if ($object->code ==
'TICKET_MSG_SENTBYMAIL') {
788 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
791 if ($object->code ==
'TICKET_MSG_PRIVATE') {
792 $object->code =
'TICKET_MSG';
794 if ($object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
795 $object->code =
'TICKET_MSG_SENTBYMAIL';
801 $object->type_code =
GETPOST(
"actioncode",
'aZ09');
804 $object->label =
GETPOST(
"label",
"alphanohtml");
805 $object->datep = $datep;
806 $object->datef = $datef;
807 $object->percentage = $percentage;
808 $object->priority =
GETPOST(
"priority",
"int");
809 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
810 $object->location =
GETPOST(
'location',
"alphanohtml");
811 $object->socid =
GETPOST(
"socid",
"int");
812 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
813 $object->socpeopleassigned = array();
814 foreach ($socpeopleassigned as $cid) {
815 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
817 $object->contact_id =
GETPOST(
"contactid",
'int');
818 if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
819 reset($object->socpeopleassigned);
820 $object->contact_id = key($object->socpeopleassigned);
822 $object->fk_project =
GETPOST(
"projectid",
'int');
823 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
825 if (
GETPOST(
"elementtype",
'alpha')) {
827 $modulecodetouseforpermissioncheck = $elProp[
'module'];
829 $hasPermissionOnLinkedObject = 0;
830 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
831 $hasPermissionOnLinkedObject = 1;
833 if ($hasPermissionOnLinkedObject) {
834 $object->fk_element =
GETPOST(
"fk_element",
'int');
835 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
839 if (!$datef && $percentage == 100) {
841 $donotclearsession = 1;
842 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), $object->errors,
'errors');
846 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
849 $listofuserid = array();
850 if (!empty($_SESSION[
'assignedtouser'])) {
852 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
853 foreach ($tmplist1 as $key => $val) {
854 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
855 $listofuserid[$val[
'id']] = $val;
859 $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
860 if ($assignedtouser) {
861 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>($user->id == $assignedtouser ? $transparency :
''));
864 $object->userassigned = array();
865 $object->userownerid = 0;
867 foreach ($listofuserid as $key => $val) {
869 $object->userownerid = $val[
'id'];
871 $object->userassigned[$val[
'id']] = array(
'id'=>$val[
'id'],
'mandatory'=>0,
'transparency'=>($user->id == $val[
'id'] ? $transparency :
''));
875 $object->transparency = $transparency;
880 $object->userdoneid =
GETPOST(
"doneby",
"int");
885 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
887 $donotclearsession = 1;
889 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
891 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
893 if (empty($object->userownerid)) {
895 $donotclearsession = 1;
897 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
901 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
908 if (
getDolGlobalString(
'RESOURCE_USED_IN_EVENT_CHECK') && $object->element ==
'action') {
909 $eventDateStart = $object->datep;
910 $eventDateEnd = $object->datef;
912 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
913 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
914 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
915 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
916 $sql .=
" WHERE ac.id <> ".((int) $object->id);
917 $sql .=
" AND er.resource_id IN (";
918 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
919 $sql .=
" WHERE element_id = ".((int) $object->id);
920 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
921 $sql .=
" AND busy = 1";
923 $sql .=
" AND er.busy = 1";
927 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
929 if (!empty($eventDateEnd)) {
930 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
934 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
935 if (!empty($eventDateEnd)) {
936 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
941 $resql = $db->query($sql);
944 $object->error = $db->lasterror();
945 $object->errors[] = $object->error;
947 if ($db->num_rows($resql) > 0) {
950 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
951 while ($obj = $db->fetch_object($resql)) {
952 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
954 $object->errors[] = $object->error;
968 $result = $object->update($user);
972 $categories =
GETPOST(
'categories',
'array');
973 $object->setCategories($categories);
975 $object->loadReminders($remindertype, 0,
false);
978 if (!empty($object->reminders)) {
979 foreach ($object->reminders as $reminder) {
980 if ($reminder->status < 1) {
981 $reminder->delete($user);
984 $object->reminders = array();
988 if ($addreminder ==
'on') {
993 $actionCommReminder->dateremind = $dateremind;
994 $actionCommReminder->typeremind = $remindertype;
995 $actionCommReminder->offsetunit = $offsetunit;
996 $actionCommReminder->offsetvalue = $offsetvalue;
997 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
998 $actionCommReminder->fk_actioncomm = $object->id;
999 if ($remindertype ==
'email') {
1000 $actionCommReminder->fk_email_template = $modelmail;
1004 foreach ($object->userassigned as $userassigned) {
1005 $actionCommReminder->fk_user = $userassigned[
'id'];
1006 $res = $actionCommReminder->create($user);
1010 $langs->load(
"errors");
1011 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1014 $donotclearsession = 1;
1020 unset($_SESSION[
'assignedtouser']);
1021 unset($_SESSION[
'assignedtoresource']);
1036 if (!empty($backtopage)) {
1037 unset($_SESSION[
'assignedtouser']);
1038 header(
"Location: ".$backtopage);
1045if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1046 $object->fetch($id);
1047 $object->fetch_optionals();
1048 $object->fetch_userassigned();
1049 $object->oldcopy =
dol_clone($object, 2);
1051 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1052 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1053 $result = $object->delete();
1056 header(
"Location: index.php");
1068if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1074 $newdate =
GETPOST(
'newdate',
'alpha');
1075 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1076 header(
"Location: ".$backtopage,
true, 307);
1080 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
1083 if ($datep != $object->datep) {
1084 if (!empty($object->datef)) {
1085 $object->datef += $datep - $object->datep;
1087 $object->datep = $datep;
1091 if (
getDolGlobalString(
'RESOURCE_USED_IN_EVENT_CHECK') && $object->element ==
'action') {
1092 $eventDateStart = $object->datep;
1093 $eventDateEnd = $object->datef;
1095 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1096 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1097 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1098 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
1099 $sql .=
" WHERE ac.id <> ".((int) $object->id);
1100 $sql .=
" AND er.resource_id IN (";
1101 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1102 $sql .=
" WHERE element_id = ".((int) $object->id);
1103 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
1104 $sql .=
" AND busy = 1";
1106 $sql .=
" AND er.busy = 1";
1110 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1112 if (!empty($eventDateEnd)) {
1113 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1117 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1118 if (!empty($eventDateEnd)) {
1119 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1124 $resql = $db->query($sql);
1127 $object->error = $db->lasterror();
1128 $object->errors[] = $object->error;
1130 if ($db->num_rows($resql) > 0) {
1133 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1134 while ($obj = $db->fetch_object($resql)) {
1135 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1137 $object->errors[] = $object->error;
1150 $result = $object->update($user);
1160 if (!empty($backtopage)) {
1161 header(
"Location: ".$backtopage,
true, 307);
1170$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1171if (empty($reshook)) {
1172 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1180$form =
new Form($db);
1183$arrayrecurrulefreq = array(
1184 'no'=>$langs->trans(
"OnceOnly"),
1185 'MONTHLY'=>$langs->trans(
"EveryMonth"),
1186 'WEEKLY'=>$langs->trans(
"EveryWeek")
1191$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1192llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1194if ($action ==
'create') {
1197 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1198 if (!empty($socpeopleassigned[0])) {
1199 $result = $contact->fetch($socpeopleassigned[0]);
1207 if (!empty($conf->use_javascript_ajax)) {
1208 print
"\n".
'<script type="text/javascript">';
1209 print
'$(document).ready(function () {
1210 function setdatefields()
1212 if ($("#fullday:checked").val() == null) {
1213 $(".fulldaystarthour").removeAttr("disabled");
1214 $(".fulldaystartmin").removeAttr("disabled");
1215 $(".fulldayendhour").removeAttr("disabled");
1216 $(".fulldayendmin").removeAttr("disabled");
1217 $("#p2").removeAttr("disabled");
1219 $(".fulldaystarthour").prop("disabled", true).val("00");
1220 $(".fulldaystartmin").prop("disabled", true).val("00");
1221 $(".fulldayendhour").prop("disabled", true).val("23");
1222 $(".fulldayendmin").prop("disabled", true).val("59");
1223 $("#p2").removeAttr("disabled");
1226 $("#fullday").change(function() {
1227 console.log("setdatefields");
1231 $("#selectcomplete").change(function() {
1232 console.log("we change the complete status - set the doneby");
1233 if ($("#selectcomplete").val() == 100) {
1234 if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).
'\');
1236 if ($(
"#selectcomplete").val() == 0) {
1237 $(
"#doneby").val(-1);
1241 $(
"#actioncode").change(
function() {
1242 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
1243 else $("#dateend").removeClass("fieldrequired");
1245 $("#aphour,#apmin").change(function() {
1246 if ($("#actioncode").val() == \'AC_RDV\') {
1247 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1248 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1249 $("#p2min").val($("#apmin").val());
1250 $("#p2day").val($("#apday").val());
1251 $("#p2month").val($("#apmonth").val());
1252 $("#p2year").val($("#apyear").val());
1253 $("#p2").val($("#ap").val());
1256 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1257 else $("#dateend").removeClass("fieldrequired");
1260 print
'</script>'.
"\n";
1263 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1264 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1265 print
'<input type="hidden" name="action" value="add">';
1266 print
'<input type="hidden" name="donotclearsession" value="1">';
1267 print
'<input type="hidden" name="page_y" value="">';
1269 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1272 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1275 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1276 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1283 print
'<table class="border centpercent">';
1287 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1289 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1290 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : ($object->type_code ? $object->type_code : $default);
1291 print
$formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1296 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>';
1299 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>';
1302 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1303 if ($userepeatevent) {
1306 print
' <div class="opacitymedium inline-block">';
1307 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1308 print
'<input type="hidden" name="recurid" value="'.(empty($object->recurid) ?
'' : $object->recurid).
'">';
1310 $selectedrecurrulefreq =
'no';
1311 $selectedrecurrulebymonthday =
'';
1312 $selectedrecurrulebyday =
'';
1313 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1314 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1315 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1319 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1320 $selectedrecurrulefreq = $reg[1];
1322 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) {
1323 $selectedrecurrulebymonthday = $reg[1];
1325 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1326 $selectedrecurrulebyday = $reg[1];
1329 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1335 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1336 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1339 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1340 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1343 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1344 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1345 print $langs->trans(
"Until").
" ";
1346 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1349 print
'<script type="text/javascript">
1350 jQuery(document).ready(function() {
1351 function init_repeat()
1353 console.log("recurrule: " + "'.$object->recurrule.
'");
1354 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1355 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1356 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1357 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1358 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1360 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1361 jQuery(".repeateventlimitdate").css("display", "inline-block");
1362 jQuery(".repeateventBYDAY").hide();
1364 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1366 jQuery(".repeateventBYMONTHDAY").hide();
1367 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1368 jQuery(".repeateventlimitdate").css("display", "inline-block");
1372 jQuery(".repeateventBYMONTHDAY").hide();
1373 jQuery(".repeateventBYDAY").hide();
1374 jQuery(".repeateventlimitdate").hide();
1378 jQuery("#recurrulefreq").change(function() {
1389 $datep = ($datep ? $datep : (is_null($object->datep) ?
'' : $object->datep));
1390 if (
GETPOST(
'datep',
'int', 1)) {
1393 $datef = ($datef ? $datef : $object->datef);
1394 if (
GETPOST(
'datef',
'int', 1)) {
1397 if (empty($datef) && !empty($datep)) {
1404 print
'<tr><td class="nowrap">';
1407 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1409 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1411 print
' <span class="hideonsmartphone"> - </span> ';
1413 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1415 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1419 print
'<tr><td class=""> </td><td></td></tr>';
1422 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1423 $listofuserid = array();
1424 $listofcontactid = array();
1425 $listofotherid = array();
1427 if (empty($donotclearsession)) {
1428 $assignedtouser =
GETPOST(
"assignedtouser") ?
GETPOST(
"assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1429 if ($assignedtouser) {
1430 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0);
1433 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1434 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1436 if (!empty($_SESSION[
'assignedtouser'])) {
1437 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1439 $firstelem = reset($listofuserid);
1440 if (isset($listofuserid[$firstelem[
'id']])) {
1441 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1444 print
'<div class="assignedtouser">';
1445 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1451 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1452 print $form->select_dolusers(GETPOSTISSET(
"doneby") ?
GETPOST(
"doneby",
'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0),
'doneby', 1);
1458 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>';
1461 if (isModEnabled(
'categorie')) {
1463 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1464 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1465 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1469 if (isModEnabled(
'resource')) {
1471 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1473 $listofresourceid = array();
1474 if (empty($donotclearsession)) {
1475 $assignedtoresource =
GETPOST(
"assignedtoresource");
1476 if ($assignedtoresource) {
1477 $listofresourceid[$assignedtoresource] = array(
'id'=>$assignedtoresource,
'mandatory'=>0);
1479 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1481 if (!empty($_SESSION[
'assignedtoresource'])) {
1482 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1484 $firstelem = reset($listofresourceid);
1485 if (isset($listofresourceid[$firstelem[
'id']])) {
1486 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1489 print
'<div class="assignedtoresource">';
1490 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1496 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1498 $percent = $complete !==
'' ? $complete : -1;
1499 if (GETPOSTISSET(
'status')) {
1501 } elseif (GETPOSTISSET(
'percentage')) {
1502 $percent =
GETPOST(
'percentage',
'int');
1504 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1506 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1510 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1516 print
'<br><hr><br>';
1519 print
'<table class="border centpercent">';
1521 if (isModEnabled(
"societe")) {
1523 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1524 if (
GETPOST(
'socid',
'int') > 0) {
1526 $societe->fetch(
GETPOST(
'socid',
'int'));
1527 print $societe->getNomUrl(1);
1528 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOST(
'socid',
'int').
'">';
1531 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1533 if (!empty($user->socid)) {
1534 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1536 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1542 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1543 $preselectedids =
GETPOST(
'socpeopleassigned',
'array');
1544 if (
GETPOST(
'contactid',
'int')) {
1545 $preselectedids[
GETPOST(
'contactid',
'int')] =
GETPOST(
'contactid',
'int');
1547 if ($origin==
'contact') {
1548 $preselectedids[
GETPOST(
'originid',
'int')] =
GETPOST(
'originid',
'int');
1552 $select_contact_default = 0;
1554 $select_contact_default = -1;
1556 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1557 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', false, 0, array(), false,
'multiple',
'contactid');
1562 if (isModEnabled(
'project')) {
1563 $langs->load(
"projects");
1565 $projectid =
GETPOST(
'projectid',
'int');
1567 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1568 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1569 print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1571 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1572 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1573 $urloption =
'?action=create&donotclearsession=1';
1577 print
"\n".
'<script type="text/javascript">';
1578 print
'$(document).ready(function () {
1579 $("#projectid").change(function () {
1580 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1581 console.log("Call url to get new list of tasks: "+url);
1582 $.get(url, function(data) {
1584 if (data) $("#taskid").html(data).select2();
1588 print
'</script>'.
"\n";
1593 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1594 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1595 $projectsListId =
false;
1596 if (!empty($projectid)) {
1597 $projectsListId = $projectid;
1600 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOST(
"projecttaskid",
'int') : (GETPOSTISSET(
"taskid") ?
GETPOST(
"taskid",
'int') :
'');
1602 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1607 if (!empty($origin) && !empty($originid)) {
1608 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1610 $hasPermissionOnLinkedObject = 0;
1613 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1614 $hasPermissionOnLinkedObject = 1;
1618 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1620 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1621 print
'<td colspan="3">';
1622 if ($hasPermissionOnLinkedObject) {
1624 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1625 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1626 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1627 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1629 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1637 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1638 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOST(
'priority',
'int') : ($object->priority ? $object->priority :
'')).
'" size="5">';
1643 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1644 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1645 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') : $object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1646 $doleditor->Create();
1650 $parameters = array();
1651 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1652 print $hookmanager->resPrint;
1653 if (empty($reshook)) {
1654 print $object->showOptionals($extrafields,
'create', $parameters);
1664 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1666 print
'<div class="reminderparameters" style="display: none;">';
1668 print
'<table class="border centpercent">';
1671 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1672 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOST(
'offsetvalue',
'int') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1673 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1677 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1678 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1683 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1684 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1691 print
"\n".
'<script type="text/javascript">';
1692 print
'$(document).ready(function () {
1693 $("#addreminder").click(function(){
1694 console.log("Click on addreminder");
1696 $(".reminderparameters").show();
1698 $(".reminderparameters").hide();
1700 $("#selectremindertype").select2("destroy");
1701 $("#selectremindertype").select2();
1702 $("#select_offsetunittype_duration").select2("destroy");
1703 $("#select_offsetunittype_duration").select2();
1704 selectremindertype();
1707 $("#selectremindertype").change(function(){
1708 selectremindertype();
1711 function selectremindertype() {
1712 console.log("Call selectremindertype");
1713 var selected_option = $("#selectremindertype option:selected").val();
1714 if(selected_option == "email") {
1715 $("#select_actioncommsendmodel_mail").closest("tr").show();
1717 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1722 print
'</script>'.
"\n";
1727 print $form->buttonsSaveCancel(
"Add");
1734 $result1 = $object->fetch($id);
1735 if ($result1 <= 0) {
1736 $langs->load(
"errors");
1737 print $langs->trans(
"ErrorRecordNotFound");
1743 $result2 = $object->fetch_thirdparty();
1744 $result2 = $object->fetch_projet();
1745 $result3 = $object->fetch_contact();
1746 $result4 = $object->fetch_userassigned();
1747 $result5 = $object->fetch_optionals();
1749 if ($listUserAssignedUpdated || $donotclearsession) {
1750 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
1752 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
1753 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
1756 $object->label =
GETPOST(
"label",
"alphanohtml");
1757 $object->datep = $datep;
1758 $object->datef = $datef;
1759 $object->percentage = $percentage;
1760 $object->priority =
GETPOST(
"priority",
"alphanohtml");
1761 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
1762 $object->location =
GETPOST(
'location',
"alphanohtml");
1763 $object->socid =
GETPOST(
"socid",
"int");
1764 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1765 foreach ($socpeopleassigned as $tmpid) {
1766 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1768 $object->contact_id =
GETPOST(
"contactid",
'int');
1769 $object->fk_project =
GETPOST(
"projectid",
'int');
1771 $object->note_private =
GETPOST(
"note",
'restricthtml');
1774 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1779 if ($object->authorid > 0) {
1780 $tmpuser =
new User($db);
1781 $res = $tmpuser->fetch($object->authorid);
1782 $object->author = $tmpuser;
1784 if ($object->usermodid > 0) {
1785 $tmpuser =
new User($db);
1786 $res = $tmpuser->fetch($object->usermodid);
1787 $object->usermod = $tmpuser;
1798 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1802 if ($action ==
'delete') {
1803 print $form->formconfirm(
"card.php?id=".urlencode($id), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1806 if ($action ==
'edit') {
1807 if (!empty($conf->use_javascript_ajax)) {
1808 print
"\n".
'<script type="text/javascript">';
1809 print
'$(document).ready(function () {
1810 function setdatefields()
1812 if ($("#fullday:checked").val() == null) {
1813 $(".fulldaystarthour").removeAttr("disabled");
1814 $(".fulldaystartmin").removeAttr("disabled");
1815 $(".fulldayendhour").removeAttr("disabled");
1816 $(".fulldayendmin").removeAttr("disabled");
1818 $(".fulldaystarthour").prop("disabled", true).val("00");
1819 $(".fulldaystartmin").prop("disabled", true).val("00");
1820 $(".fulldayendhour").prop("disabled", true).val("23");
1821 $(".fulldayendmin").prop("disabled", true).val("59");
1825 $("#fullday").change(function() {
1828 $("#actioncode").change(function() {
1829 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1830 else $("#dateend").removeClass("fieldrequired");
1833 print
'</script>'.
"\n";
1836 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1837 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1838 print
'<input type="hidden" name="action" value="update">';
1839 print
'<input type="hidden" name="id" value="'.$id.
'">';
1840 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1841 print
'<input type="hidden" name="page_y" value="">';
1843 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1845 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && ! preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code)) {
1846 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1851 print
'<table class="border tableforfield" width="100%">';
1854 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.$object->id.
'</td></tr>';
1857 if (
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && $object->elementtype !=
"ticket") {
1858 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1859 if ($object->type_code !=
'AC_OTH_AUTO') {
1860 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1861 print
$formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') : $object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1863 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1864 print $object->getTypePicto();
1865 print $langs->trans(
"Action".$object->type_code);
1871 if ($object->elementtype ==
'ticket') {
1872 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
1873 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1874 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code) ?
' checked' :
'').
'></td></tr>';
1878 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>';
1881 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' :
'').
'>';
1882 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1945 print
'<tr><td class="nowrap">';
1950 print
'</td><td td colspan="3">';
1953 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 0,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1954 } elseif (
GETPOST(
"afaire") == 2) {
1955 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1957 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1959 print
' <span class="hideonsmartphone"> - </span> ';
1961 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1962 } elseif (
GETPOST(
"afaire") == 2) {
1963 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1965 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1969 print
'<tr><td class=""> </td><td></td></tr>';
1972 $listofuserid = array();
1973 if (empty($donotclearsession)) {
1974 if ($object->userownerid > 0) {
1975 $listofuserid[$object->userownerid] = array(
1976 'id'=>$object->userownerid,
1979 'transparency'=>$object->transparency,
1980 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
1981 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
1984 if (!empty($object->userassigned)) {
1986 $tmplist1 = $object->userassigned;
1987 foreach ($tmplist1 as $key => $val) {
1988 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
1989 $listofuserid[$val[
'id']] = $val;
1993 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1995 if (!empty($_SESSION[
'assignedtouser'])) {
1996 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1999 $listofcontactid = $object->socpeopleassigned;
2000 $listofotherid = $object->otherassigned;
2002 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
2003 print
'<div class="assignedtouser">';
2004 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
2016 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td colspan="3">';
2017 print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1,
'doneby', 1);
2023 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
2027 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
2028 $percent = GETPOSTISSET(
"percentage") ?
GETPOST(
"percentage",
"int") : $object->percentage;
2029 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
2033 if (isModEnabled(
'categorie')) {
2034 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2035 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
2037 $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
2038 $arrayselected = array();
2039 foreach ($cats as $cat) {
2040 $arrayselected[] = $cat->id;
2042 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2049 print
'<br><hr><br>';
2052 print
'<table class="border tableforfield centpercent">';
2054 if (isModEnabled(
"societe")) {
2056 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2060 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2063 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth200');
2068 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2069 print
'<div class="maxwidth200onsmartphone">';
2070 print
img_picto(
'',
'contact',
'class="paddingrightonly"').$form->selectcontacts(!
getDolGlobalString(
'MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT') ? $object->socid : 0, array_keys($object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'minwidth300 widthcentpercentminusx', false, 0, 0, array(),
'multiple',
'contactid');
2077 if (isModEnabled(
'project')) {
2078 $langs->load(
"projects");
2080 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2081 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2082 $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');
2083 if ($numprojet == 0) {
2084 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>';
2091 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2092 print
'<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
2097 if (!empty($object->fk_element) && !empty($object->elementtype)) {
2098 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2100 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2102 if ($object->elementtype ==
'task' && isModEnabled(
'project')) {
2103 print
'<td id="project-task-input-container" >';
2105 $urloption =
'?action=create&donotclearsession=1';
2106 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2109 print
"\n".
'<script type="text/javascript" >';
2110 print
'$(document).ready(function () {
2111 $("#projectid").change(function () {
2112 var url = "'.$url.
'&projectid="+$("#projectid").val();
2113 $.get(url, function(data) {
2114 console.log($( data ).find("#fk_element").html());
2115 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2119 print
'</script>'.
"\n";
2121 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
2122 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2128 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2129 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2137 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2139 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2140 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2141 $doleditor->Create();
2145 $parameters = array();
2146 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2147 print $hookmanager->resPrint;
2148 if (empty($reshook)) {
2149 print $object->showOptionals($extrafields,
'edit', $parameters);
2156 $filteruserid = $user->id;
2157 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2160 $object->loadReminders(
'', $filteruserid,
false);
2164 if (count($object->reminders) > 0) {
2165 $checked =
'checked';
2166 $keys = array_keys($object->reminders);
2167 $firstreminderId = array_shift($keys);
2169 $actionCommReminder = $object->reminders[$firstreminderId];
2173 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2174 $actionCommReminder->offsetunit =
'i';
2175 $actionCommReminder->typeremind =
'email';
2178 if ($object->datep <
dol_now()) {
2182 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>';
2184 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2188 print
'<table class="border centpercent">';
2191 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2192 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2193 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2197 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2198 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2202 if ($actionCommReminder->typeremind ==
'browser') {
2203 $hide =
'style="display:none;"';
2208 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2209 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2215 print
"\n".
'<script type="text/javascript">';
2216 print
'$(document).ready(function () {
2217 $("#addreminder").click(function(){
2219 $(".reminderparameters").show();
2221 $(".reminderparameters").hide();
2225 $("#selectremindertype").change(function(){
2226 var selected_option = $("#selectremindertype option:selected").val();
2227 if(selected_option == "email") {
2228 $("#select_actioncommsendmodel_mail").closest("tr").show();
2230 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2235 print
'</script>'.
"\n";
2242 print $form->buttonsSaveCancel();
2251 if ($action ==
'clone') {
2252 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', array(),
'yes', 1);
2256 $parameters = array();
2257 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2258 if (empty($reshook)) {
2259 $formconfirm.=$hookmanager->resPrint;
2260 } elseif ($reshook > 0) {
2261 $formconfirm=$hookmanager->resPrint;
2269 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2270 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
2271 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
2272 $linkback .=
'</a>';
2273 $linkback .=
'</li>';
2274 $linkback .=
'<li class="noborder litext">';
2275 $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').
'">';
2276 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
2277 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
2278 $linkback .=
'</a>';
2279 $linkback .=
'</li>';
2280 $linkback .=
'<li class="noborder litext">';
2281 $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').
'">';
2282 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
2283 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
2284 $linkback .=
'</a>';
2285 $linkback .=
'</li>';
2286 $linkback .=
'<li class="noborder litext">';
2287 $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').
'">';
2288 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
2289 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
2290 $linkback .=
'</a>';
2291 $linkback .=
'</li>';
2292 $linkback .=
'<li class="noborder litext">';
2293 $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').
'">';
2294 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
2295 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
2296 $linkback .=
'</a>';
2299 $parameters = array();
2300 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
2301 if (empty($reshook)) {
2302 $linkback .= $hookmanager->resPrint;
2303 } elseif ($reshook > 1) {
2304 $linkback = $hookmanager->resPrint;
2309 $morehtmlref =
'<div class="refidno">';
2313 if (isModEnabled(
'project')) {
2314 $langs->load(
"projects");
2316 if ($usercancreate) {
2317 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2318 if ($action !=
'classify') {
2319 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2321 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2323 if (!empty($object->fk_project)) {
2325 $proj->fetch($object->fk_project);
2326 $morehtmlref .= $proj->getNomUrl(1);
2328 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2333 $morehtmlref .=
'</div>';
2336 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2338 print
'<div class="fichecenter">';
2339 print
'<div class="fichehalfleft">';
2341 print
'<div class="underbanner clearboth"></div>';
2344 print
'<table class="border tableforfield" width="100%">';
2348 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2349 print $object->getTypePicto();
2350 print $langs->trans(
"Action".$object->type_code);
2355 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2358 if ($object->recurid) {
2359 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag($object->recurid).
'</td></tr>';
2368 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2373 if (empty($object->fulldayevent)) {
2377 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2379 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2386 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2387 if (empty($object->fulldayevent)) {
2391 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2393 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2400 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
2404 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2405 $listofuserid = array();
2406 if (empty($donotclearsession)) {
2407 if ($object->userownerid > 0) {
2408 $listofuserid[$object->userownerid] = array(
2409 'id'=>$object->userownerid,
2410 'transparency'=>$object->transparency,
2411 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2412 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2415 if (!empty($object->userassigned)) {
2417 $tmplist1 = $object->userassigned;
2418 foreach ($tmplist1 as $key => $val) {
2419 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2420 $listofuserid[$val[
'id']] = $val;
2424 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2426 if (!empty($_SESSION[
'assignedtouser'])) {
2427 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2431 $listofcontactid = array();
2432 $listofotherid = array();
2433 print
'<div class="assignedtouser">';
2434 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2444 print
' </td></tr>';
2448 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
2449 if ($object->userdoneid > 0) {
2450 $tmpuser =
new User($db);
2451 $tmpuser->fetch($object->userdoneid);
2452 print $tmpuser->getNomUrl(1);
2458 if (isModEnabled(
'categorie')) {
2459 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2460 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2468 print
'<div class="fichehalfright">';
2470 print
'<div class="underbanner clearboth"></div>';
2471 print
'<table class="border tableforfield centpercent">';
2473 if (isModEnabled(
"societe")) {
2475 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2476 print
'<td>'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2477 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL') {
2478 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2479 print
"<br>".dol_print_phone($object->thirdparty->phone);
2485 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2488 if (!empty($object->socpeopleassigned)) {
2489 foreach ($object->socpeopleassigned as $cid => $Tab) {
2491 $result = $contact->fetch($cid);
2498 print $contact->getNomUrl(1);
2499 if ($object->type_code ==
'AC_TEL') {
2500 if (!empty($contact->phone_pro)) {
2501 print
'('.dol_print_phone($contact->phone_pro).
')';
2504 print
'<div class="paddingright"></div>';
2508 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2514 print
'<tr><td class="nowrap" class="titlefield">'.$langs->trans(
"Priority").
'</td><td>';
2515 print($object->priority ? $object->priority :
'');
2520 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project'))) {
2521 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2522 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2526 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2534 if (!empty($object->email_msgid)) {
2535 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2536 print
'<td>'.dol_escape_htmltag($object->email_subject).
'</td></tr>';
2537 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2538 print
'<td>'.dol_escape_htmltag($object->email_from).
'</td></tr>';
2539 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2540 print
'<td>'.dol_escape_htmltag($object->email_to).
'</td></tr>';
2541 if (!empty($object->email_tocc)) {
2542 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2543 print
'<td>'.dol_escape_htmltag($object->email_tocc).
'</td></tr>';
2548 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2553 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2557 $filteruserid = $user->id;
2558 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2561 $object->loadReminders(
'', $filteruserid,
false);
2563 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2565 if (count($object->reminders) > 0) {
2566 $tmpuserstatic =
new User($db);
2568 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2569 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2570 if ($actioncommreminder->fk_user > 0) {
2571 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2572 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2574 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2576 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2577 print
' - <span class="opacitymedium">';
2578 print $langs->trans(
"NotSent");
2580 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2581 print
' - <span class="opacitymedium">';
2582 print $langs->trans(
"Done");
2584 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2585 print
' - <span class="opacitymedium">';
2586 print $form->textwithpicto($langs->trans(
"Error"), $actioncommreminder->lasterror);
2600 print
'<div class="clearboth"></div>';
2609 print
'<div class="tabsAction">';
2611 $parameters = array();
2612 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2613 if (empty($reshook)) {
2614 if ($action !=
'edit') {
2615 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2616 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2617 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2619 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2622 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2623 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2624 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>';
2626 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2629 if ($user->hasRight(
'agenda',
'allactions',
'delete') ||
2630 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2631 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2633 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2640 if ($action !=
'edit') {
2642 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2643 print
'<a name="builddoc"></a>';
2649 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2650 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2652 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2653 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2656 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2658 print
'</div><div class="fichehalfright">';
2661 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...
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0)
Clean a string to keep only desirable HTML tags.
dol_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_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.