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">';
2071 $searchSocid = ($object->socid > 0) ? $object->socid : (
getDolGlobalString(
'MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT') ? 0 : -1);
2073 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2074 print $form->selectcontacts(
2076 array_keys($object->socpeopleassigned),
2077 'socpeopleassigned[]',
2082 'minwidth300 widthcentpercentminusx',
2097 if (isModEnabled(
'project')) {
2098 $langs->load(
"projects");
2100 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2101 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2102 $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');
2103 if ($numprojet == 0) {
2104 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>';
2111 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2112 print
'<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
2117 if (!empty($object->fk_element) && !empty($object->elementtype)) {
2118 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2120 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2122 if ($object->elementtype ==
'task' && isModEnabled(
'project')) {
2123 print
'<td id="project-task-input-container" >';
2125 $urloption =
'?action=create&donotclearsession=1';
2126 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2129 print
"\n".
'<script type="text/javascript" >';
2130 print
'$(document).ready(function () {
2131 $("#projectid").change(function () {
2132 var url = "'.$url.
'&projectid="+$("#projectid").val();
2133 $.get(url, function(data) {
2134 console.log($( data ).find("#fk_element").html());
2135 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2139 print
'</script>'.
"\n";
2141 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
2142 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2148 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2149 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2157 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2159 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2160 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2161 $doleditor->Create();
2165 $parameters = array();
2166 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2167 print $hookmanager->resPrint;
2168 if (empty($reshook)) {
2169 print $object->showOptionals($extrafields,
'edit', $parameters);
2176 $filteruserid = $user->id;
2177 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2180 $object->loadReminders(
'', $filteruserid,
false);
2184 if (count($object->reminders) > 0) {
2185 $checked =
'checked';
2186 $keys = array_keys($object->reminders);
2187 $firstreminderId = array_shift($keys);
2189 $actionCommReminder = $object->reminders[$firstreminderId];
2193 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2194 $actionCommReminder->offsetunit =
'i';
2195 $actionCommReminder->typeremind =
'email';
2198 if ($object->datep <
dol_now()) {
2202 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>';
2204 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2208 print
'<table class="border centpercent">';
2211 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2212 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2213 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2217 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2218 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2222 if ($actionCommReminder->typeremind ==
'browser') {
2223 $hide =
'style="display:none;"';
2228 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2229 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2235 print
"\n".
'<script type="text/javascript">';
2236 print
'$(document).ready(function () {
2237 $("#addreminder").click(function(){
2239 $(".reminderparameters").show();
2241 $(".reminderparameters").hide();
2245 $("#selectremindertype").change(function(){
2246 var selected_option = $("#selectremindertype option:selected").val();
2247 if(selected_option == "email") {
2248 $("#select_actioncommsendmodel_mail").closest("tr").show();
2250 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2255 print
'</script>'.
"\n";
2262 print $form->buttonsSaveCancel();
2271 if ($action ==
'clone') {
2272 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', array(),
'yes', 1);
2276 $parameters = array();
2277 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2278 if (empty($reshook)) {
2279 $formconfirm.=$hookmanager->resPrint;
2280 } elseif ($reshook > 0) {
2281 $formconfirm=$hookmanager->resPrint;
2289 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2290 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
2291 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
2292 $linkback .=
'</a>';
2293 $linkback .=
'</li>';
2294 $linkback .=
'<li class="noborder litext">';
2295 $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').
'">';
2296 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
2297 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
2298 $linkback .=
'</a>';
2299 $linkback .=
'</li>';
2300 $linkback .=
'<li class="noborder litext">';
2301 $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').
'">';
2302 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
2303 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
2304 $linkback .=
'</a>';
2305 $linkback .=
'</li>';
2306 $linkback .=
'<li class="noborder litext">';
2307 $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').
'">';
2308 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
2309 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
2310 $linkback .=
'</a>';
2311 $linkback .=
'</li>';
2312 $linkback .=
'<li class="noborder litext">';
2313 $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').
'">';
2314 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
2315 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
2316 $linkback .=
'</a>';
2319 $parameters = array();
2320 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
2321 if (empty($reshook)) {
2322 $linkback .= $hookmanager->resPrint;
2323 } elseif ($reshook > 1) {
2324 $linkback = $hookmanager->resPrint;
2329 $morehtmlref =
'<div class="refidno">';
2333 if (isModEnabled(
'project')) {
2334 $langs->load(
"projects");
2336 if ($usercancreate) {
2337 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2338 if ($action !=
'classify') {
2339 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2341 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2343 if (!empty($object->fk_project)) {
2345 $proj->fetch($object->fk_project);
2346 $morehtmlref .= $proj->getNomUrl(1);
2348 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2353 $morehtmlref .=
'</div>';
2356 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2358 print
'<div class="fichecenter">';
2359 print
'<div class="fichehalfleft">';
2361 print
'<div class="underbanner clearboth"></div>';
2364 print
'<table class="border tableforfield" width="100%">';
2368 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2369 print $object->getTypePicto();
2370 print $langs->trans(
"Action".$object->type_code);
2375 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2378 if ($object->recurid) {
2379 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag($object->recurid).
'</td></tr>';
2388 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2393 if (empty($object->fulldayevent)) {
2397 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2399 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2406 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2407 if (empty($object->fulldayevent)) {
2411 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2413 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2420 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
2424 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2425 $listofuserid = array();
2426 if (empty($donotclearsession)) {
2427 if ($object->userownerid > 0) {
2428 $listofuserid[$object->userownerid] = array(
2429 'id'=>$object->userownerid,
2430 'transparency'=>$object->transparency,
2431 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2432 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2435 if (!empty($object->userassigned)) {
2437 $tmplist1 = $object->userassigned;
2438 foreach ($tmplist1 as $key => $val) {
2439 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2440 $listofuserid[$val[
'id']] = $val;
2444 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2446 if (!empty($_SESSION[
'assignedtouser'])) {
2447 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2451 $listofcontactid = array();
2452 $listofotherid = array();
2453 print
'<div class="assignedtouser">';
2454 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2464 print
' </td></tr>';
2468 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
2469 if ($object->userdoneid > 0) {
2470 $tmpuser =
new User($db);
2471 $tmpuser->fetch($object->userdoneid);
2472 print $tmpuser->getNomUrl(1);
2478 if (isModEnabled(
'categorie')) {
2479 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2480 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2488 print
'<div class="fichehalfright">';
2490 print
'<div class="underbanner clearboth"></div>';
2491 print
'<table class="border tableforfield centpercent">';
2493 if (isModEnabled(
"societe")) {
2495 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2496 print
'<td>'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2497 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL') {
2498 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2499 print
"<br>".dol_print_phone($object->thirdparty->phone);
2505 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2508 if (!empty($object->socpeopleassigned)) {
2509 foreach ($object->socpeopleassigned as $cid => $Tab) {
2511 $result = $contact->fetch($cid);
2518 print $contact->getNomUrl(1);
2519 if ($object->type_code ==
'AC_TEL') {
2520 if (!empty($contact->phone_pro)) {
2521 print
'('.dol_print_phone($contact->phone_pro).
')';
2524 print
'<div class="paddingright"></div>';
2528 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2535 print
'<tr><td class="nowrap" class="titlefield">' . $langs->trans(
"Priority") .
'</td><td>';
2536 print($object->priority ? $object->priority :
'');
2542 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project'))) {
2543 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2544 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2548 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2556 if (!empty($object->email_msgid)) {
2557 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2558 print
'<td>'.dol_escape_htmltag($object->email_subject).
'</td></tr>';
2559 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2560 print
'<td>'.dol_escape_htmltag($object->email_from).
'</td></tr>';
2561 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2562 print
'<td>'.dol_escape_htmltag($object->email_to).
'</td></tr>';
2563 if (!empty($object->email_tocc)) {
2564 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2565 print
'<td>'.dol_escape_htmltag($object->email_tocc).
'</td></tr>';
2570 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2575 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2579 $filteruserid = $user->id;
2580 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2583 $object->loadReminders(
'', $filteruserid,
false);
2585 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2587 if (count($object->reminders) > 0) {
2588 $tmpuserstatic =
new User($db);
2590 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2591 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2592 if ($actioncommreminder->fk_user > 0) {
2593 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2594 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2596 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2598 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2599 print
' - <span class="opacitymedium">';
2600 print $langs->trans(
"NotSent");
2602 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2603 print
' - <span class="opacitymedium">';
2604 print $langs->trans(
"Done");
2606 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2607 print
' - <span class="opacitymedium">';
2608 print $form->textwithpicto($langs->trans(
"Error"), $actioncommreminder->lasterror);
2622 print
'<div class="clearboth"></div>';
2631 print
'<div class="tabsAction">';
2633 $parameters = array();
2634 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2635 if (empty($reshook)) {
2636 if ($action !=
'edit') {
2637 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2638 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2639 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2641 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2644 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2645 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2646 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>';
2648 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2651 if ($user->hasRight(
'agenda',
'allactions',
'delete') ||
2652 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2653 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2655 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2662 if ($action !=
'edit') {
2664 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2665 print
'<a name="builddoc"></a>';
2671 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2672 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2674 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2675 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2678 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2680 print
'</div><div class="fichehalfright">';
2683 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.