34 require
'../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
49 require_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');
72 $offsetvalue =
GETPOST(
'offsetvalue',
'int');
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');
78 if ($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],
'tzuser');
102 $socid =
GETPOST(
'socid',
'int');
104 if ($user->socid && ($socid != $user->socid)) {
109 $donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
123 if ($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'));
141 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
146 $TRemindTypes = array();
147 if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) {
148 $TRemindTypes[
'browser'] = array(
'label'=>$langs->trans(
'BrowserPush'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_BROWSER) ? 1 : 0));
150 if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) {
151 $TRemindTypes[
'email'] = array(
'label'=>$langs->trans(
'EMail'),
'disabled'=>(empty($conf->global->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;
167 if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
168 $idtoremove =
GETPOST(
'removedassigned');
170 if (!empty($_SESSION[
'assignedtouser'])) {
171 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'], 1);
173 $tmpassigneduserids = array();
176 foreach ($tmpassigneduserids as $key => $val) {
177 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
178 unset($tmpassigneduserids[$key]);
182 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
183 $donotclearsession = 1;
184 if ($action ==
'add') {
187 if ($action ==
'update') {
191 $listUserAssignedUpdated =
true;
195 if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
197 if (
GETPOST(
'assignedtouser') > 0) {
198 $assignedtouser = array();
199 if (!empty($_SESSION[
'assignedtouser'])) {
200 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
202 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id'=>
GETPOST(
'assignedtouser'),
'transparency'=>
GETPOST(
'transparency'),
'mandatory'=>1);
203 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
205 $donotclearsession = 1;
206 if ($action ==
'add') {
209 if ($action ==
'update') {
213 $listUserAssignedUpdated =
true;
217 if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
218 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
220 $object->setProject(
GETPOST(
'projectid',
'int'));
224 if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes') {
225 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
230 if (!empty($object->socpeopleassigned)) {
231 reset($object->socpeopleassigned);
232 $object->contact_id = key($object->socpeopleassigned);
234 $result = $object->createFromClone($user,
GETPOST(
'socid',
'int'));
236 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
247 if (empty($reshook) && $action ==
'add') {
250 if (empty($backtopage)) {
252 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
254 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
258 if (!empty($socpeopleassigned[0])) {
259 $result = $contact->fetch($socpeopleassigned[0]);
263 header(
"Location: ".$backtopage);
267 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
273 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
274 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
276 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
277 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
281 if (!$datef && $percentage == 100) {
282 $error++; $donotclearsession = 1;
284 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
287 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !
GETPOST(
'label')) {
288 $error++; $donotclearsession = 1;
290 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
295 $error++; $donotclearsession = 1;
297 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
299 $object->type_code =
GETPOST(
'actioncode',
'aZ09');
305 $object->fulldayevent = ($fulldayevent ? 1 : 0);
306 $object->location =
GETPOST(
"location",
'alphanohtml');
307 $object->label =
GETPOST(
'label',
'alphanohtml');
309 if (
GETPOST(
"elementtype",
'alpha')) {
310 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
312 $hasPermissionOnLinkedObject = 0;
313 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
314 $hasPermissionOnLinkedObject = 1;
316 if ($hasPermissionOnLinkedObject) {
317 $object->fk_element =
GETPOST(
"fk_element",
'int');
318 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
323 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
324 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
326 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
327 $object->label = $langs->transnoentitiesnoconv(
"Action".$object->type_code).
"\n";
329 $cactioncomm->fetch($object->type_code);
330 $object->label = $cactioncomm->label;
336 $taskid =
GETPOST(
'taskid',
'int');
337 if (!empty($taskid)) {
338 $taskProject =
new Task($db);
339 if ($taskProject->fetch($taskid) > 0) {
340 $object->fk_project = $taskProject->fk_project;
343 $object->fk_element = $taskid;
344 $object->elementtype =
'task';
347 $object->datep = $datep;
348 $object->datef = $datef;
349 $object->percentage = $percentage;
350 $object->duree = (((int)
GETPOST(
'dureehour') * 60) + (
int)
GETPOST(
'dureemin')) * 60;
352 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
354 $listofuserid = array();
355 if (!empty($_SESSION[
'assignedtouser'])) {
356 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
359 foreach ($listofuserid as $key => $value) {
361 if ($value[
'id'] > 0) {
362 $object->userownerid = $value[
'id'];
364 $object->transparency = $transparency;
367 $object->userassigned[$value[
'id']] = array(
'id'=>$value[
'id'],
'transparency'=>$transparency);
373 if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) {
375 $object->userdoneid =
GETPOST(
"doneby",
"int");
379 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
382 $object->contact = $contact;
385 if (
GETPOST(
'socid',
'int') > 0) {
386 $object->socid =
GETPOST(
'socid',
'int');
387 $object->fetch_thirdparty();
389 $object->societe = $object->thirdparty;
393 if (empty($object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
394 $error++; $donotclearsession = 1;
396 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
398 if ($object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
399 $error++; $donotclearsession = 1;
401 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
405 $error++; $donotclearsession = 1;
407 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
410 foreach ($socpeopleassigned as $cid) {
411 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
413 if (!empty($object->socpeopleassigned)) {
414 reset($object->socpeopleassigned);
415 $object->contact_id = key($object->socpeopleassigned);
419 $ret = $extrafields->setOptionalsFromPost(
null, $object);
429 $selectedrecurrulefreq =
'no';
430 $selectedrecurrulebymonthday =
'';
431 $selectedrecurrulebyday =
'';
432 $object->recurrule =
GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
433 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' &&
GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
434 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' &&
GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
436 $reg1 = array(); $reg2 = array(); $reg3 = array();
437 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) {
438 $selectedrecurrulefreq = $reg1[1];
440 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) {
441 $selectedrecurrulebymonthday = $reg2[1];
443 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) {
444 $selectedrecurrulebyday = $reg3[1];
448 $eventisrecurring = 0;
449 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
450 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
451 $eventisrecurring = 1;
455 unset($object->recurid);
456 unset($object->recurrule);
457 unset($object->recurdateend);
461 $idaction = $object->create($user);
464 if (!$object->error) {
466 $categories =
GETPOST(
'categories',
'array');
467 $object->setCategories($categories);
469 unset($_SESSION[
'assignedtouser']);
472 if ($user->id != $object->userownerid) {
473 $moreparam =
"filtert=-1";
477 if ($addreminder ==
'on') {
482 $actionCommReminder->dateremind = $dateremind;
483 $actionCommReminder->typeremind = $remindertype;
484 $actionCommReminder->offsetunit = $offsetunit;
485 $actionCommReminder->offsetvalue = $offsetvalue;
486 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
487 $actionCommReminder->fk_actioncomm = $object->id;
488 if ($remindertype ==
'email') {
489 $actionCommReminder->fk_email_template = $modelmail;
493 foreach ($object->userassigned as $userassigned) {
494 $actionCommReminder->fk_user = $userassigned[
'id'];
495 $res = $actionCommReminder->create($user);
500 $langs->load(
"errors");
501 $error = $langs->trans(
'ErrorReminderActionCommCreation');
503 $action =
'create'; $donotclearsession = 1;
514 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
534 $langs->load(
"errors");
535 $error = $langs->trans($object->error);
537 $action =
'create'; $donotclearsession = 1;
542 $action =
'create'; $donotclearsession = 1;
545 if ($eventisrecurring) {
547 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
549 $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 :
'tzuser');
553 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
554 $firstday = $selectedrecurrulebymonthday;
555 $firstmonth =
GETPOST(
"apday") > $selectedrecurrulebymonthday ?
GETPOST(
"apmonth",
'int') + 1 :
GETPOST(
"apmonth",
'int');
556 $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 :
'tzuser');
563 $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 :
'tzuser');
568 while ($datep <= $repeateventlimitdate && !$error) {
569 $finalobject = clone $object;
572 $finalobject->datep = $datep;
573 $finalobject->datef = $datef;
575 $idaction = $finalobject->create($user);
578 if (!$finalobject->error) {
580 $categories =
GETPOST(
'categories',
'array');
581 $finalobject->setCategories($categories);
583 unset($_SESSION[
'assignedtouser']);
586 if ($user->id != $finalobject->userownerid) {
587 $moreparam =
"filtert=-1";
591 if ($addreminder ==
'on') {
596 $actionCommReminder->dateremind = $dateremind;
597 $actionCommReminder->typeremind = $remindertype;
598 $actionCommReminder->offsetunit = $offsetunit;
599 $actionCommReminder->offsetvalue = $offsetvalue;
600 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
601 $actionCommReminder->fk_actioncomm = $finalobject->id;
602 if ($remindertype ==
'email') {
603 $actionCommReminder->fk_email_template = $modelmail;
607 foreach ($finalobject->userassigned as $userassigned) {
608 $actionCommReminder->fk_user = $userassigned[
'id'];
609 $res = $actionCommReminder->create($user);
614 $langs->load(
"errors");
615 $error = $langs->trans(
'ErrorReminderActionCommCreation');
617 $action =
'create'; $donotclearsession = 1;
628 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
638 $langs->load(
"errors");
639 $error = $langs->trans($finalobject->error);
641 $action =
'create'; $donotclearsession = 1;
646 $action =
'create'; $donotclearsession = 1;
661 if (!empty($backtopage) && !$error) {
662 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
663 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
664 } elseif ($idaction) {
665 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
667 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
676 if (empty($reshook) && $action ==
'update') {
677 if (empty($cancel)) {
678 $fulldayevent =
GETPOST(
'fullday');
679 $aphour =
GETPOST(
'aphour',
'int');
680 $apmin =
GETPOST(
'apmin',
'int');
681 $p2hour =
GETPOST(
'p2hour',
'int');
682 $p2min =
GETPOST(
'p2min',
'int');
683 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
700 $object->fetch_optionals();
701 $object->fetch_userassigned();
708 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
709 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
711 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
712 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
715 if ($object->elementtype ==
'ticket') {
717 if ($object->code ==
'TICKET_MSG') {
718 $object->code =
'TICKET_MSG_PRIVATE';
720 if ($object->code ==
'TICKET_MSG_SENTBYMAIL') {
721 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
724 if ($object->code ==
'TICKET_MSG_PRIVATE') {
725 $object->code =
'TICKET_MSG';
727 if ($object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
728 $object->code =
'TICKET_MSG_SENTBYMAIL';
734 $object->type_code =
GETPOST(
"actioncode",
'aZ09');
737 $object->label =
GETPOST(
"label",
"alphanohtml");
738 $object->datep = $datep;
739 $object->datef = $datef;
740 $object->percentage = $percentage;
741 $object->priority =
GETPOST(
"priority",
"int");
742 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
743 $object->location =
GETPOST(
'location',
"alphanohtml");
744 $object->socid =
GETPOST(
"socid",
"int");
745 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
746 $object->socpeopleassigned = array();
747 foreach ($socpeopleassigned as $cid) {
748 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
750 $object->contact_id =
GETPOST(
"contactid",
'int');
751 if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
752 reset($object->socpeopleassigned);
753 $object->contact_id = key($object->socpeopleassigned);
755 $object->fk_project =
GETPOST(
"projectid",
'int');
756 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
758 if (
GETPOST(
"elementtype",
'alpha')) {
759 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
761 $hasPermissionOnLinkedObject = 0;
762 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
763 $hasPermissionOnLinkedObject = 1;
765 if ($hasPermissionOnLinkedObject) {
766 $object->fk_element =
GETPOST(
"fk_element",
'int');
767 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
771 if (!$datef && $percentage == 100) {
772 $error++; $donotclearsession = 1;
773 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), $object->errors,
'errors');
777 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
780 $listofuserid = array();
781 if (!empty($_SESSION[
'assignedtouser'])) {
783 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
784 foreach ($tmplist1 as $key => $val) {
785 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
786 $listofuserid[$val[
'id']] = $val;
790 $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
791 if ($assignedtouser) {
792 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>($user->id == $assignedtouser ? $transparency :
''));
795 $object->userassigned = array(); $object->userownerid = 0;
797 foreach ($listofuserid as $key => $val) {
799 $object->userownerid = $val[
'id'];
801 $object->userassigned[$val[
'id']] = array(
'id'=>$val[
'id'],
'mandatory'=>0,
'transparency'=>($user->id == $val[
'id'] ? $transparency :
''));
805 $object->transparency = $transparency;
808 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
810 $object->userdoneid =
GETPOST(
"doneby",
"int");
816 $error++; $donotclearsession = 1;
818 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
820 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
822 if (empty($object->userownerid)) {
823 $error++; $donotclearsession = 1;
825 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
829 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
836 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
837 $eventDateStart = $object->datep;
838 $eventDateEnd = $object->datef;
840 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
841 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
842 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
843 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
844 $sql .=
" WHERE ac.id <> ".((int) $object->id);
845 $sql .=
" AND er.resource_id IN (";
846 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
847 $sql .=
" WHERE element_id = ".((int) $object->id);
848 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
849 $sql .=
" AND busy = 1";
851 $sql .=
" AND er.busy = 1";
855 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
857 if (!empty($eventDateEnd)) {
858 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
862 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
863 if (!empty($eventDateEnd)) {
864 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
869 $resql = $db->query(
$sql);
872 $object->error = $db->lasterror();
873 $object->errors[] = $object->error;
875 if ($db->num_rows($resql) > 0) {
878 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
879 while ($obj = $db->fetch_object($resql)) {
880 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
882 $object->errors[] = $object->error;
896 $result = $object->update($user);
900 $categories =
GETPOST(
'categories',
'array');
901 $object->setCategories($categories);
903 $object->loadReminders($remindertype, 0,
false);
904 if (!empty($object->reminders) && $object->datep >
dol_now()) {
905 foreach ($object->reminders as $reminder) {
906 $reminder->delete($user);
908 $object->reminders = array();
912 if ($addreminder ==
'on' && $object->datep >
dol_now()) {
917 $actionCommReminder->dateremind = $dateremind;
918 $actionCommReminder->typeremind = $remindertype;
919 $actionCommReminder->offsetunit = $offsetunit;
920 $actionCommReminder->offsetvalue = $offsetvalue;
921 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
922 $actionCommReminder->fk_actioncomm = $object->id;
923 if ($remindertype ==
'email') {
924 $actionCommReminder->fk_email_template = $modelmail;
928 foreach ($object->userassigned as $userassigned) {
929 $actionCommReminder->fk_user = $userassigned[
'id'];
930 $res = $actionCommReminder->create($user);
934 $langs->load(
"errors");
935 $error = $langs->trans(
'ErrorReminderActionCommCreation');
937 $action =
'create'; $donotclearsession = 1;
943 unset($_SESSION[
'assignedtouser']);
958 if (!empty($backtopage)) {
959 unset($_SESSION[
'assignedtouser']);
960 header(
"Location: ".$backtopage);
967 if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
969 $object->fetch_optionals();
970 $object->fetch_userassigned();
973 if ($user->hasRight(
'agenda',
'myactions',
'delete')
974 || $user->rights->agenda->allactions->delete) {
975 $result = $object->delete();
978 header(
"Location: index.php");
990 if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
996 $newdate =
GETPOST(
'newdate',
'alpha');
997 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
998 header(
"Location: ".$backtopage);
1002 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
1005 if ($datep != $object->datep) {
1006 if (!empty($object->datef)) {
1007 $object->datef += $datep - $object->datep;
1009 $object->datep = $datep;
1013 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
1014 $eventDateStart = $object->datep;
1015 $eventDateEnd = $object->datef;
1017 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1018 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1019 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1020 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
1021 $sql .=
" WHERE ac.id <> ".((int) $object->id);
1022 $sql .=
" AND er.resource_id IN (";
1023 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1024 $sql .=
" WHERE element_id = ".((int) $object->id);
1025 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
1026 $sql .=
" AND busy = 1";
1028 $sql .=
" AND er.busy = 1";
1032 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1034 if (!empty($eventDateEnd)) {
1035 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1039 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1040 if (!empty($eventDateEnd)) {
1041 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1046 $resql = $db->query(
$sql);
1049 $object->error = $db->lasterror();
1050 $object->errors[] = $object->error;
1052 if ($db->num_rows($resql) > 0) {
1055 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1056 while ($obj = $db->fetch_object($resql)) {
1057 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1059 $object->errors[] = $object->error;
1072 $result = $object->update($user);
1082 if (!empty($backtopage)) {
1083 header(
"Location: ".$backtopage);
1092 $permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1093 if (empty($reshook)) {
1094 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1105 $arrayrecurrulefreq = array(
1106 'no'=>$langs->trans(
"OnceOnly"),
1107 'MONTHLY'=>$langs->trans(
"EveryMonth"),
1108 'WEEKLY'=>$langs->trans(
"EveryWeek")
1113 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1116 if ($action ==
'create') {
1119 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1120 if (!empty($socpeopleassigned[0])) {
1121 $result = $contact->fetch($socpeopleassigned[0]);
1129 if (!empty($conf->use_javascript_ajax)) {
1130 print
"\n".
'<script type="text/javascript">';
1131 print
'$(document).ready(function () {
1132 function setdatefields()
1134 if ($("#fullday:checked").val() == null) {
1135 $(".fulldaystarthour").removeAttr("disabled");
1136 $(".fulldaystartmin").removeAttr("disabled");
1137 $(".fulldayendhour").removeAttr("disabled");
1138 $(".fulldayendmin").removeAttr("disabled");
1139 $("#p2").removeAttr("disabled");
1141 $(".fulldaystarthour").prop("disabled", true).val("00");
1142 $(".fulldaystartmin").prop("disabled", true).val("00");
1143 $(".fulldayendhour").prop("disabled", true).val("23");
1144 $(".fulldayendmin").prop("disabled", true).val("59");
1145 $("#p2").removeAttr("disabled");
1148 $("#fullday").change(function() {
1149 console.log("setdatefields");
1153 $("#selectcomplete").change(function() {
1154 console.log("we change the complete status - set the doneby");
1155 if ($("#selectcomplete").val() == 100) {
1156 if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).
'\');
1158 if ($(
"#selectcomplete").val() == 0) {
1159 $(
"#doneby").val(-1);
1163 $(
"#actioncode").change(
function() {
1164 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
1165 else $("#dateend").removeClass("fieldrequired");
1167 $("#aphour,#apmin").change(function() {
1168 if ($("#actioncode").val() == \'AC_RDV\') {
1169 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1170 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1171 $("#p2min").val($("#apmin").val());
1172 $("#p2day").val($("#apday").val());
1173 $("#p2month").val($("#apmonth").val());
1174 $("#p2year").val($("#apyear").val());
1175 $("#p2").val($("#ap").val());
1178 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1179 else $("#dateend").removeClass("fieldrequired");
1182 print
'</script>'.
"\n";
1185 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1186 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1187 print
'<input type="hidden" name="action" value="add">';
1188 print
'<input type="hidden" name="donotclearsession" value="1">';
1189 print
'<input type="hidden" name="page_y" value="">';
1191 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1193 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1194 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1197 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1198 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1205 print
'<table class="border centpercent">';
1208 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1209 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1211 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1212 $selectedvalue =
GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : ($object->type_code ? $object->type_code : $default);
1213 print
$formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1218 print
'<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE) ?
' class="fieldrequired titlefieldcreate"' :
'').
'>'.$langs->trans(
"Label").
'</td><td><input type="text" id="label" name="label" class="soixantepercent" value="'.
GETPOST(
'label').
'"></td></tr>';
1221 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>';
1224 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1225 if ($userepeatevent) {
1228 print
' <div class="opacitymedium inline-block">';
1229 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1230 print
'<input type="hidden" name="recurid" value="'.(empty($object->recurid) ?
'' : $object->recurid).
'">';
1232 $selectedrecurrulefreq =
'no';
1233 $selectedrecurrulebymonthday =
'';
1234 $selectedrecurrulebyday =
'';
1235 $object->recurrule =
GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1236 $object->recurrule .=
GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1237 $object->recurrule .=
GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1241 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1242 $selectedrecurrulefreq = $reg[1];
1244 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) {
1245 $selectedrecurrulebymonthday = $reg[1];
1247 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1248 $selectedrecurrulebyday = $reg[1];
1251 print
$form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1257 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1258 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1261 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1262 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1265 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1266 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1267 print $langs->trans(
"Until").
" ";
1268 print
$form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1271 print
'<script type="text/javascript">
1272 jQuery(document).ready(function() {
1273 function init_repeat()
1275 console.log("recurrule: " + "'.$object->recurrule.
'");
1276 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1277 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1278 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1279 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1280 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1282 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1283 jQuery(".repeateventlimitdate").css("display", "inline-block");
1284 jQuery(".repeateventBYDAY").hide();
1286 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1288 jQuery(".repeateventBYMONTHDAY").hide();
1289 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1290 jQuery(".repeateventlimitdate").css("display", "inline-block");
1294 jQuery(".repeateventBYMONTHDAY").hide();
1295 jQuery(".repeateventBYDAY").hide();
1296 jQuery(".repeateventlimitdate").hide();
1300 jQuery("#recurrulefreq").change(function() {
1311 $datep = ($datep ? $datep : (is_null($object->datep) ?
'' : $object->datep));
1312 if (
GETPOST(
'datep',
'int', 1)) {
1315 $datef = ($datef ? $datef : $object->datef);
1316 if (
GETPOST(
'datef',
'int', 1)) {
1319 if (empty($datef) && !empty($datep)) {
1320 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
1321 $datef =
dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS),
'h');
1326 print
'<tr><td class="nowrap">';
1329 print
$form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1331 print
$form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1333 print
' <span class="hideonsmartphone"> - </span> ';
1335 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1337 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1341 print
'<tr><td class=""> </td><td></td></tr>';
1344 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1345 $listofuserid = array();
1346 $listofcontactid = array();
1347 $listofotherid = array();
1349 if (empty($donotclearsession)) {
1350 $assignedtouser =
GETPOST(
"assignedtouser") ?
GETPOST(
"assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1351 if ($assignedtouser) {
1352 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0);
1355 $listofuserid[$assignedtouser][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1356 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1358 if (!empty($_SESSION[
'assignedtouser'])) {
1359 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1361 $firstelem = reset($listofuserid);
1362 if (isset($listofuserid[$firstelem[
'id']])) {
1363 $listofuserid[$firstelem[
'id']][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1366 print
'<div class="assignedtouser">';
1367 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1372 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1373 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1374 print
$form->select_dolusers(
GETPOSTISSET(
"doneby") ?
GETPOST(
"doneby",
'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0),
'doneby', 1);
1379 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1380 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>';
1384 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1386 $percent = $complete !==
'' ? $complete : -1;
1390 $percent =
GETPOST(
'percentage',
'int');
1392 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1394 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1398 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1403 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1404 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1405 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1412 print
'<br><hr><br>';
1415 print
'<table class="border centpercent">';
1419 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1420 if (
GETPOST(
'socid',
'int') > 0) {
1422 $societe->fetch(
GETPOST(
'socid',
'int'));
1423 print $societe->getNomUrl(1);
1424 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOST(
'socid',
'int').
'">';
1427 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1429 if (!empty($user->socid)) {
1430 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300');
1432 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
1438 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1439 $preselectedids =
GETPOST(
'socpeopleassigned',
'array');
1440 if (
GETPOST(
'contactid',
'int')) {
1441 $preselectedids[
GETPOST(
'contactid',
'int')] =
GETPOST(
'contactid',
'int');
1443 if ($origin==
'contact') $preselectedids[
GETPOST(
'originid',
'int')] =
GETPOST(
'originid',
'int');
1444 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1445 print
$form->selectcontacts(empty($conf->global->MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT) ?
GETPOST(
'socid',
'int') : 0, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 quatrevingtpercent',
false, 0, array(),
false,
'multiple',
'contactid');
1451 $langs->load(
"projects");
1453 $projectid =
GETPOST(
'projectid',
'int');
1455 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1456 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1457 print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
1459 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1460 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1461 $urloption =
'?action=create&donotclearsession=1';
1465 print
"\n".
'<script type="text/javascript">';
1466 print
'$(document).ready(function () {
1467 $("#projectid").change(function () {
1468 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1469 console.log("Call url to get new list of tasks: "+url);
1470 $.get(url, function(data) {
1472 if (data) $("#taskid").html(data).select2();
1476 print
'</script>'.
"\n";
1481 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1482 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1483 $projectsListId =
false;
1484 if (!empty($projectid)) {
1485 $projectsListId = $projectid;
1490 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1495 if (!empty($origin) && !empty($originid)) {
1496 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1498 $hasPermissionOnLinkedObject = 0;
1499 if ($user->hasRight($origin,
'read')) {
1500 $hasPermissionOnLinkedObject = 1;
1504 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1506 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1507 print
'<td colspan="3">';
1508 if ($hasPermissionOnLinkedObject) {
1510 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1511 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1512 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1513 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1515 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1522 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1523 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1524 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOST(
'priority',
'int') : ($object->priority ? $object->priority :
'')).
'" size="5">';
1529 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1530 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1531 $doleditor =
new DolEditor(
'note', (
GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') : $object->note_private),
'', 120,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1532 $doleditor->Create();
1537 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1538 print $hookmanager->resPrint;
1539 if (empty($reshook)) {
1540 print $object->showOptionals($extrafields,
'create',
$parameters);
1550 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1552 print
'<div class="reminderparameters" style="display: none;">';
1554 print
'<table class="border centpercent">';
1557 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1558 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOST(
'offsetvalue',
'int') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1559 print
$form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1563 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1564 print
$form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1569 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1570 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1577 print
"\n".
'<script type="text/javascript">';
1578 print
'$(document).ready(function () {
1579 $("#addreminder").click(function(){
1580 console.log("Click on addreminder");
1582 $(".reminderparameters").show();
1584 $(".reminderparameters").hide();
1586 $("#selectremindertype").select2("destroy");
1587 $("#selectremindertype").select2();
1588 $("#select_offsetunittype_duration").select2("destroy");
1589 $("#select_offsetunittype_duration").select2();
1592 $("#selectremindertype").change(function(){
1593 console.log("Change on selectremindertype");
1594 var selected_option = $("#selectremindertype option:selected").val();
1595 if(selected_option == "email") {
1596 $("#select_actioncommsendmodel_mail").closest("tr").show();
1598 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1602 print
'</script>'.
"\n";
1607 print
$form->buttonsSaveCancel(
"Add");
1614 $result1 = $object->fetch($id);
1615 if ($result1 <= 0) {
1616 $langs->load(
"errors");
1617 print $langs->trans(
"ErrorRecordNotFound");
1623 $result2 = $object->fetch_thirdparty();
1624 $result2 = $object->fetch_projet();
1625 $result3 = $object->fetch_contact();
1626 $result4 = $object->fetch_userassigned();
1627 $result5 = $object->fetch_optionals();
1629 if ($listUserAssignedUpdated || $donotclearsession) {
1630 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
1632 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
1633 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
1636 $object->label =
GETPOST(
"label",
"alphanohtml");
1637 $object->datep = $datep;
1638 $object->datef = $datef;
1639 $object->percentage = $percentage;
1640 $object->priority =
GETPOST(
"priority",
"alphanohtml");
1641 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
1642 $object->location =
GETPOST(
'location',
"alpanohtml");
1643 $object->socid =
GETPOST(
"socid",
"int");
1644 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1645 foreach ($socpeopleassigned as $tmpid) {
1646 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1648 $object->contact_id =
GETPOST(
"contactid",
'int');
1649 $object->fk_project =
GETPOST(
"projectid",
'int');
1651 $object->note_private =
GETPOST(
"note",
'restricthtml');
1654 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1659 if ($object->authorid > 0) {
1660 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
1662 if ($object->usermodid > 0) {
1663 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
1674 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1678 if ($action ==
'delete') {
1679 print
$form->formconfirm(
"card.php?id=".urlencode($id), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1682 if ($action ==
'edit') {
1683 if (!empty($conf->use_javascript_ajax)) {
1684 print
"\n".
'<script type="text/javascript">';
1685 print
'$(document).ready(function () {
1686 function setdatefields()
1688 if ($("#fullday:checked").val() == null) {
1689 $(".fulldaystarthour").removeAttr("disabled");
1690 $(".fulldaystartmin").removeAttr("disabled");
1691 $(".fulldayendhour").removeAttr("disabled");
1692 $(".fulldayendmin").removeAttr("disabled");
1694 $(".fulldaystarthour").prop("disabled", true).val("00");
1695 $(".fulldaystartmin").prop("disabled", true).val("00");
1696 $(".fulldayendhour").prop("disabled", true).val("23");
1697 $(".fulldayendmin").prop("disabled", true).val("59");
1701 $("#fullday").change(function() {
1704 $("#actioncode").change(function() {
1705 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1706 else $("#dateend").removeClass("fieldrequired");
1709 print
'</script>'.
"\n";
1712 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1713 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1714 print
'<input type="hidden" name="action" value="update">';
1715 print
'<input type="hidden" name="id" value="'.$id.
'">';
1716 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1717 print
'<input type="hidden" name="page_y" value="">';
1719 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1721 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code)) {
1722 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1727 print
'<table class="border tableforfield" width="100%">';
1730 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.$object->id.
'</td></tr>';
1733 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->elementtype !=
"ticket") {
1734 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1735 if ($object->type_code !=
'AC_OTH_AUTO') {
1736 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1737 print
$formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') : $object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1739 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1740 print $object->getTypePicto();
1741 print $langs->trans(
"Action".$object->type_code);
1747 if ($object->elementtype ==
'ticket') {
1748 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
1749 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1750 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code) ?
' checked' :
'').
'></td></tr>';
1754 print
'<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE) ?
' class="fieldrequired titlefieldcreate"' :
'').
'>'.$langs->trans(
"Title").
'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.$object->label.
'"></td></tr>';
1757 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' :
'').
'>';
1758 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1821 print
'<tr><td class="nowrap">';
1826 print
'</td><td td colspan="3">';
1829 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 0,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1830 } elseif (
GETPOST(
"afaire") == 2) {
1831 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1833 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1835 print
' <span class="hideonsmartphone"> - </span> ';
1837 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1838 } elseif (
GETPOST(
"afaire") == 2) {
1839 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1841 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1845 print
'<tr><td class=""> </td><td></td></tr>';
1848 $listofuserid = array();
1849 if (empty($donotclearsession)) {
1850 if ($object->userownerid > 0) {
1851 $listofuserid[$object->userownerid] = array(
1852 'id'=>$object->userownerid,
1855 'transparency'=>$object->transparency,
1856 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
1857 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
1860 if (!empty($object->userassigned)) {
1862 $tmplist1 = $object->userassigned;
1863 foreach ($tmplist1 as $key => $val) {
1864 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
1865 $listofuserid[$val[
'id']] = $val;
1869 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1871 if (!empty($_SESSION[
'assignedtouser'])) {
1872 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1875 $listofcontactid = $object->socpeopleassigned;
1876 $listofotherid = $object->otherassigned;
1878 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
1879 print
'<div class="assignedtouser">';
1880 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1891 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1892 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td colspan="3">';
1893 print
$form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1,
'doneby', 1);
1898 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1899 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
1903 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
1904 $percent =
GETPOSTISSET(
"percentage") ?
GETPOST(
"percentage",
"int") : $object->percentage;
1905 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1910 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1911 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1913 $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
1914 $arrayselected = array();
1915 foreach ($cats as $cat) {
1916 $arrayselected[] = $cat->id;
1918 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1925 print
'<br><hr><br>';
1928 print
'<table class="border tableforfield centpercent">';
1932 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
1934 print
'<div class="maxwidth200onsmartphone">';
1936 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1939 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth200');
1944 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
1945 print
'<div class="maxwidth200onsmartphone">';
1946 print
img_picto(
'',
'contact',
'class="paddingrightonly"').$form->selectcontacts(empty($conf->global->MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT) ? $object->socid : 0, array_keys($object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'quatrevingtpercent',
false, 0, 0, array(),
'multiple',
'contactid');
1954 $langs->load(
"projects");
1956 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
1957 print
img_picto(
'',
'project',
'class="paddingrightonly"');
1958 $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth500');
1959 if ($numprojet == 0) {
1960 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>';
1966 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1967 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
1968 print
'<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
1973 if (!empty($object->fk_element) && !empty($object->elementtype)) {
1974 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1976 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
1978 if ($object->elementtype ==
'task' &&
isModEnabled(
'project')) {
1979 print
'<td id="project-task-input-container" >';
1981 $urloption =
'?action=create&donotclearsession=1';
1982 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
1985 print
"\n".
'<script type="text/javascript" >';
1986 print
'$(document).ready(function () {
1987 $("#projectid").change(function () {
1988 var url = "'.$url.
'&projectid="+$("#projectid").val();
1989 $.get(url, function(data) {
1990 console.log($( data ).find("#fk_element").html());
1991 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
1995 print
'</script>'.
"\n";
1997 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
1998 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2004 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2005 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2013 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2015 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2016 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2017 $doleditor->Create();
2022 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
2023 print $hookmanager->resPrint;
2024 if (empty($reshook)) {
2025 print $object->showOptionals($extrafields,
'edit',
$parameters);
2032 $filteruserid = $user->id;
2033 if ($user->rights->agenda->allactions->read) {
2036 $object->loadReminders(
'', $filteruserid,
false);
2040 if (count($object->reminders) > 0) {
2041 $checked =
'checked';
2042 $keys = array_keys($object->reminders);
2043 $firstreminderId = array_shift($keys);
2045 $actionCommReminder = $object->reminders[$firstreminderId];
2049 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2050 $actionCommReminder->offsetunit =
'i';
2051 $actionCommReminder->typeremind =
'email';
2054 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder" '.$checked.
'><br>';
2056 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2060 print
'<table class="border centpercent">';
2063 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2064 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2065 print
$form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2069 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2070 print
$form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2074 if ($actionCommReminder->typeremind ==
'browser') {
2075 $hide =
'style="display:none;"';
2080 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2081 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2087 print
"\n".
'<script type="text/javascript">';
2088 print
'$(document).ready(function () {
2089 $("#addreminder").click(function(){
2091 $(".reminderparameters").show();
2093 $(".reminderparameters").hide();
2097 $("#selectremindertype").change(function(){
2098 var selected_option = $("#selectremindertype option:selected").val();
2099 if(selected_option == "email") {
2100 $("#select_actioncommsendmodel_mail").closest("tr").show();
2102 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2107 print
'</script>'.
"\n";
2114 print
$form->buttonsSaveCancel();
2123 if ($action ==
'clone') {
2124 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', array(),
'yes', 1);
2129 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2130 if (empty($reshook))
$formconfirm.=$hookmanager->resPrint;
2131 elseif ($reshook > 0)
$formconfirm=$hookmanager->resPrint;
2138 $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2139 $linkback .=
img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"');
2140 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("BackToList").'</span>';
2141 $linkback .= '</a>';
2142 $linkback .= '</li>';
2143 $linkback .= '<li class="noborder litext">';
2144 $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').'">';
2145 $linkback .=
img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"');
2146 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewCal").'</span>';
2147 $linkback .= '</a>';
2148 $linkback .= '</li>';
2149 $linkback .= '<li class="noborder litext">';
2150 $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').'">';
2151 $linkback .=
img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"');
2152 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewWeek").'</span>';
2153 $linkback .= '</a>';
2154 $linkback .= '</li>';
2155 $linkback .= '<li class="noborder litext">';
2156 $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').'">';
2157 $linkback .=
img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"');
2158 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewDay").'</span>';
2159 $linkback .= '</a>';
2160 $linkback .= '</li>';
2161 $linkback .= '<li class="noborder litext">';
2162 $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').'">';
2163 $linkback .=
img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"');
2164 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewPerUser").'</span>';
2165 $linkback .= '</a>';
2169 $reshook = $hookmanager->executeHooks('addCalendarView',
$parameters, $object, $action);
2170 if (empty($reshook)) {
2171 $linkback .= $hookmanager->resPrint;
2172 } elseif ($reshook > 1) {
2173 $linkback = $hookmanager->resPrint;
2178 $morehtmlref =
'<div class="refidno">';
2183 $langs->load(
"projects");
2185 if ($usercancreate) {
2186 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2187 if ($action !=
'classify') {
2188 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2190 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2192 if (!empty($object->fk_project)) {
2194 $proj->fetch($object->fk_project);
2195 $morehtmlref .= $proj->getNomUrl(1);
2197 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2202 $morehtmlref .=
'</div>';
2205 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2207 print
'<div class="fichecenter">';
2208 print
'<div class="fichehalfleft">';
2210 print
'<div class="underbanner clearboth"></div>';
2213 print
'<table class="border tableforfield" width="100%">';
2216 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
2217 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2218 print $object->getTypePicto();
2219 print $langs->trans(
"Action".$object->type_code);
2224 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2227 if ($object->recurid) {
2228 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag($object->recurid).
'</td></tr>';
2232 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2237 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2242 if (empty($object->fulldayevent)) {
2246 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2248 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2255 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2256 if (empty($object->fulldayevent)) {
2260 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2262 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2268 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2269 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
2273 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2274 $listofuserid = array();
2275 if (empty($donotclearsession)) {
2276 if ($object->userownerid > 0) {
2277 $listofuserid[$object->userownerid] = array(
2278 'id'=>$object->userownerid,
2279 'transparency'=>$object->transparency,
2280 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2281 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2284 if (!empty($object->userassigned)) {
2286 $tmplist1 = $object->userassigned;
2287 foreach ($tmplist1 as $key => $val) {
2288 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2289 $listofuserid[$val[
'id']] = $val;
2293 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2295 if (!empty($_SESSION[
'assignedtouser'])) {
2296 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2300 $listofcontactid = array();
2301 $listofotherid = array();
2302 print
'<div class="assignedtouser">';
2303 print
$form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2313 print
' </td></tr>';
2316 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
2317 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
2318 if ($object->userdoneid > 0) {
2319 $tmpuser =
new User($db);
2320 $tmpuser->fetch($object->userdoneid);
2321 print $tmpuser->getNomUrl(1);
2328 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2329 print
$form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2337 print
'<div class="fichehalfright">';
2339 print
'<div class="underbanner clearboth"></div>';
2340 print
'<table class="border tableforfield centpercent">';
2344 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2345 print
'<td>'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2346 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL') {
2347 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2348 print
"<br>".dol_print_phone($object->thirdparty->phone);
2354 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2357 if (!empty($object->socpeopleassigned)) {
2358 foreach ($object->socpeopleassigned as $cid => $Tab) {
2360 $result = $contact->fetch($cid);
2367 print $contact->getNomUrl(1);
2368 if ($object->type_code ==
'AC_TEL') {
2369 if (!empty($contact->phone_pro)) {
2370 print
'('.dol_print_phone($contact->phone_pro).
')';
2373 print
'<div class="paddingright"></div>';
2377 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2383 print
'<tr><td class="nowrap" class="titlefield">'.$langs->trans(
"Priority").
'</td><td>';
2384 print ($object->priority ? $object->priority :
'');
2389 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project'))) {
2390 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2391 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2395 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2403 if (!empty($object->email_msgid)) {
2404 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2405 print
'<td>'.dol_escape_htmltag($object->email_subject).
'</td></tr>';
2406 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2407 print
'<td>'.dol_escape_htmltag($object->email_from).
'</td></tr>';
2408 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2409 print
'<td>'.dol_escape_htmltag($object->email_to).
'</td></tr>';
2410 if (!empty($object->email_tocc)) {
2411 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2412 print
'<td>'.dol_escape_htmltag($object->email_tocc).
'</td></tr>';
2417 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2422 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2425 if (!empty($conf->global->AGENDA_REMINDER_EMAIL) || !empty($conf->global->AGENDA_REMINDER_BROWSER)) {
2426 $filteruserid = $user->id;
2427 if ($user->rights->agenda->allactions->read) {
2430 $object->loadReminders(
'', $filteruserid,
false);
2432 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2434 if (count($object->reminders) > 0) {
2435 $tmpuserstatic =
new User($db);
2437 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2438 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2439 if ($actioncommreminder->fk_user > 0) {
2440 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2441 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2443 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2444 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2445 print
' - <span class="opacitymedium">';
2446 print $langs->trans(
"NotSent");
2448 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2449 print
' - <span class="opacitymedium">';
2450 print $langs->trans(
"Done");
2464 print
'<div class="clearboth"></div>';
2473 print
'<div class="tabsAction">';
2476 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2477 if (empty($reshook)) {
2478 if ($action !=
'edit') {
2479 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2480 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2481 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2483 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2486 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2487 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2488 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>';
2490 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2493 if ($user->rights->agenda->allactions->delete ||
2494 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2495 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2497 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2504 if ($action !=
'edit') {
2505 if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) {
2506 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2507 print
'<a name="builddoc"></a>';
2513 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2514 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2516 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2517 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2520 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2522 print
'</div><div class="fichehalfright">';
2525 print
'</div></div>';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
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 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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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...
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
$formconfirm
if ($action == 'delbookkeepingyear') {
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.