34 require
'../../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
54 $langs->loadLangs(array(
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"));
57 $action =
GETPOST(
'action',
'aZ09');
58 $cancel =
GETPOST(
'cancel',
'alpha');
59 $backtopage =
GETPOST(
'backtopage',
'alpha');
60 $socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
61 $origin =
GETPOST(
'origin',
'alpha');
62 $originid =
GETPOST(
'originid',
'int');
63 $confirm =
GETPOST(
'confirm',
'alpha');
65 $fulldayevent =
GETPOST(
'fullday',
'alpha');
67 $aphour =
GETPOST(
'aphour',
'int');
68 $apmin =
GETPOST(
'apmin',
'int');
69 $p2hour =
GETPOST(
'p2hour',
'int');
70 $p2min =
GETPOST(
'p2min',
'int');
72 $addreminder =
GETPOST(
'addreminder',
'alpha');
73 $offsetvalue =
GETPOST(
'offsetvalue',
'int');
74 $offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
75 $remindertype =
GETPOST(
'selectremindertype',
'aZ09');
76 $modelmail =
GETPOST(
'actioncommsendmodel_mail',
'int');
77 $complete =
GETPOST(
'complete',
'alpha');
78 $private =
GETPOST(
'private',
'alphanohtml');
79 if ($complete ==
'na' || $complete == -2) {
86 $datep =
dol_mktime(
'00',
'00', 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
87 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
95 if (
GETPOST(
'datep') ==
'now') {
97 } elseif (preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
98 $datep =
dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1],
'tzuser');
103 $socid =
GETPOST(
'socid',
'int');
105 if ($user->socid && ($socid != $user->socid)) {
110 $donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
124 if ($id > 0 && $action !=
'add') {
125 $ret = $object->fetch($id);
127 $ret = $object->fetch_optionals();
128 $ret1 = $object->fetch_userassigned();
130 if ($ret < 0 || $ret1 < 0) {
136 $extrafields->fetch_name_optionals_label($object->table_element);
139 $hookmanager->initHooks(array(
'actioncard',
'globalcard'));
142 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
147 $TRemindTypes = array();
148 if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) {
149 $TRemindTypes[
'browser'] = array(
'label'=>$langs->trans(
'BrowserPush'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_BROWSER) ? 1 : 0));
151 if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) {
152 $TRemindTypes[
'email'] = array(
'label'=>$langs->trans(
'EMail'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_EMAIL) ? 1 : 0));
155 $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'));
157 $result =
restrictedArea($user,
'agenda', $object->id,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
159 $usercancreate = $user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create);
166 $listUserAssignedUpdated =
false;
168 if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
169 $idtoremove =
GETPOST(
'removedassigned');
171 if (!empty($_SESSION[
'assignedtouser'])) {
172 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'], 1);
174 $tmpassigneduserids = array();
177 foreach ($tmpassigneduserids as $key => $val) {
178 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
179 unset($tmpassigneduserids[$key]);
183 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
184 $donotclearsession = 1;
185 if ($action ==
'add') {
188 if ($action ==
'update') {
192 $listUserAssignedUpdated =
true;
196 if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
198 if (
GETPOST(
'assignedtouser') > 0) {
199 $assignedtouser = array();
200 if (!empty($_SESSION[
'assignedtouser'])) {
201 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
203 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id'=>
GETPOST(
'assignedtouser'),
'transparency'=>
GETPOST(
'transparency'),
'mandatory'=>1);
204 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
206 $donotclearsession = 1;
207 if ($action ==
'add') {
210 if ($action ==
'update') {
214 $listUserAssignedUpdated =
true;
218 if (empty($reshook) && $action ==
'classin' && ($user->rights->agenda->allactions->create ||
219 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) {
221 $object->setProject(
GETPOST(
'projectid',
'int'));
225 if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes') {
226 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
231 if (!empty($object->socpeopleassigned)) {
232 reset($object->socpeopleassigned);
233 $object->contact_id = key($object->socpeopleassigned);
235 $result = $object->createFromClone($user,
GETPOST(
'socid',
'int'));
237 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
248 if (empty($reshook) && $action ==
'add') {
251 if (empty($backtopage)) {
253 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
255 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
259 if (!empty($socpeopleassigned[0])) {
260 $result = $contact->fetch($socpeopleassigned[0]);
264 header(
"Location: ".$backtopage);
268 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
274 $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');
275 $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');
277 $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');
278 $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');
282 if (!$datef && $percentage == 100) {
283 $error++; $donotclearsession = 1;
285 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
288 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !
GETPOST(
'label')) {
289 $error++; $donotclearsession = 1;
291 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
296 $error++; $donotclearsession = 1;
298 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
300 $object->type_code =
GETPOST(
'actioncode',
'aZ09');
306 $object->fulldayevent = ($fulldayevent ? 1 : 0);
307 $object->location =
GETPOST(
"location",
'alphanohtml');
308 $object->label =
GETPOST(
'label',
'alphanohtml');
310 if (
GETPOST(
"elementtype",
'alpha')) {
311 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
313 $hasPermissionOnLinkedObject = 0;
314 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
315 $hasPermissionOnLinkedObject = 1;
317 if ($hasPermissionOnLinkedObject) {
318 $object->fk_element =
GETPOST(
"fk_element",
'int');
319 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
324 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
325 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
327 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
328 $object->label = $langs->transnoentitiesnoconv(
"Action".$object->type_code).
"\n";
330 $cactioncomm->fetch($object->type_code);
331 $object->label = $cactioncomm->label;
337 $taskid =
GETPOST(
'taskid',
'int');
338 if (!empty($taskid)) {
339 $taskProject =
new Task($db);
340 if ($taskProject->fetch($taskid) > 0) {
341 $object->fk_project = $taskProject->fk_project;
344 $object->fk_element = $taskid;
345 $object->elementtype =
'task';
348 $object->datep = $datep;
349 $object->datef = $datef;
350 $object->percentage = $percentage;
351 $object->duree = (((int)
GETPOST(
'dureehour') * 60) + (
int)
GETPOST(
'dureemin')) * 60;
353 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
355 $listofuserid = array();
356 if (!empty($_SESSION[
'assignedtouser'])) {
357 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
360 foreach ($listofuserid as $key => $value) {
362 if ($value[
'id'] > 0) {
363 $object->userownerid = $value[
'id'];
365 $object->transparency = $transparency;
368 $object->userassigned[$value[
'id']] = array(
'id'=>$value[
'id'],
'transparency'=>$transparency);
374 if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) {
376 $object->userdoneid =
GETPOST(
"doneby",
"int");
380 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
383 $object->contact = $contact;
386 if (
GETPOST(
'socid',
'int') > 0) {
387 $object->socid =
GETPOST(
'socid',
'int');
388 $object->fetch_thirdparty();
390 $object->societe = $object->thirdparty;
394 if (empty($object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
395 $error++; $donotclearsession = 1;
397 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
399 if ($object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
400 $error++; $donotclearsession = 1;
402 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
406 $error++; $donotclearsession = 1;
408 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
411 foreach ($socpeopleassigned as $cid) {
412 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
414 if (!empty($object->socpeopleassigned)) {
415 reset($object->socpeopleassigned);
416 $object->contact_id = key($object->socpeopleassigned);
420 $ret = $extrafields->setOptionalsFromPost(
null, $object);
430 $selectedrecurrulefreq =
'no';
431 $selectedrecurrulebymonthday =
'';
432 $selectedrecurrulebyday =
'';
433 $object->recurrule =
GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
434 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' &&
GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
435 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' &&
GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
437 $reg1 = array(); $reg2 = array(); $reg3 = array();
438 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) {
439 $selectedrecurrulefreq = $reg1[1];
441 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) {
442 $selectedrecurrulebymonthday = $reg2[1];
444 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) {
445 $selectedrecurrulebyday = $reg3[1];
449 $eventisrecurring = 0;
450 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
451 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
452 $eventisrecurring = 1;
456 unset($object->recurid);
457 unset($object->recurrule);
458 unset($object->recurdateend);
462 $idaction = $object->create($user);
465 if (!$object->error) {
467 $categories =
GETPOST(
'categories',
'array');
468 $object->setCategories($categories);
470 unset($_SESSION[
'assignedtouser']);
473 if ($user->id != $object->userownerid) {
474 $moreparam =
"filtert=-1";
478 if ($addreminder ==
'on') {
483 $actionCommReminder->dateremind = $dateremind;
484 $actionCommReminder->typeremind = $remindertype;
485 $actionCommReminder->offsetunit = $offsetunit;
486 $actionCommReminder->offsetvalue = $offsetvalue;
487 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
488 $actionCommReminder->fk_actioncomm = $object->id;
489 if ($remindertype ==
'email') {
490 $actionCommReminder->fk_email_template = $modelmail;
494 foreach ($object->userassigned as $userassigned) {
495 $actionCommReminder->fk_user = $userassigned[
'id'];
496 $res = $actionCommReminder->create($user);
501 $langs->load(
"errors");
502 $error = $langs->trans(
'ErrorReminderActionCommCreation');
504 $action =
'create'; $donotclearsession = 1;
515 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
535 $langs->load(
"errors");
536 $error = $langs->trans($object->error);
538 $action =
'create'; $donotclearsession = 1;
543 $action =
'create'; $donotclearsession = 1;
546 if ($eventisrecurring) {
548 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
550 $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');
554 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
555 $firstday = $selectedrecurrulebymonthday;
556 $firstmonth =
GETPOST(
"apday") > $selectedrecurrulebymonthday ?
GETPOST(
"apmonth",
'int') + 1 :
GETPOST(
"apmonth",
'int');
557 $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');
564 $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');
569 while ($datep <= $repeateventlimitdate && !$error) {
570 $finalobject = clone $object;
573 $finalobject->datep = $datep;
574 $finalobject->datef = $datef;
576 $idaction = $finalobject->create($user);
579 if (!$finalobject->error) {
581 $categories =
GETPOST(
'categories',
'array');
582 $finalobject->setCategories($categories);
584 unset($_SESSION[
'assignedtouser']);
587 if ($user->id != $finalobject->userownerid) {
588 $moreparam =
"filtert=-1";
592 if ($addreminder ==
'on') {
597 $actionCommReminder->dateremind = $dateremind;
598 $actionCommReminder->typeremind = $remindertype;
599 $actionCommReminder->offsetunit = $offsetunit;
600 $actionCommReminder->offsetvalue = $offsetvalue;
601 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
602 $actionCommReminder->fk_actioncomm = $finalobject->id;
603 if ($remindertype ==
'email') {
604 $actionCommReminder->fk_email_template = $modelmail;
608 foreach ($finalobject->userassigned as $userassigned) {
609 $actionCommReminder->fk_user = $userassigned[
'id'];
610 $res = $actionCommReminder->create($user);
615 $langs->load(
"errors");
616 $error = $langs->trans(
'ErrorReminderActionCommCreation');
618 $action =
'create'; $donotclearsession = 1;
629 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
639 $langs->load(
"errors");
640 $error = $langs->trans($finalobject->error);
642 $action =
'create'; $donotclearsession = 1;
647 $action =
'create'; $donotclearsession = 1;
662 if (!empty($backtopage) && !$error) {
663 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
664 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
665 } elseif ($idaction) {
666 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
668 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
677 if (empty($reshook) && $action ==
'update') {
678 if (empty($cancel)) {
679 $fulldayevent =
GETPOST(
'fullday');
680 $aphour =
GETPOST(
'aphour',
'int');
681 $apmin =
GETPOST(
'apmin',
'int');
682 $p2hour =
GETPOST(
'p2hour',
'int');
683 $p2min =
GETPOST(
'p2min',
'int');
684 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
701 $object->fetch_optionals();
702 $object->fetch_userassigned();
709 $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');
710 $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');
712 $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');
713 $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');
716 if ($object->elementtype ==
'ticket') {
718 if ($object->code ==
'TICKET_MSG') {
719 $object->code =
'TICKET_MSG_PRIVATE';
721 if ($object->code ==
'TICKET_MSG_SENTBYMAIL') {
722 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
725 if ($object->code ==
'TICKET_MSG_PRIVATE') {
726 $object->code =
'TICKET_MSG';
728 if ($object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
729 $object->code =
'TICKET_MSG_SENTBYMAIL';
735 $object->type_code =
GETPOST(
"actioncode",
'aZ09');
738 $object->label =
GETPOST(
"label",
"alphanohtml");
739 $object->datep = $datep;
740 $object->datef = $datef;
741 $object->percentage = $percentage;
742 $object->priority =
GETPOST(
"priority",
"int");
743 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
744 $object->location =
GETPOST(
'location',
"alphanohtml");
745 $object->socid =
GETPOST(
"socid",
"int");
746 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
747 $object->socpeopleassigned = array();
748 foreach ($socpeopleassigned as $cid) {
749 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
751 $object->contact_id =
GETPOST(
"contactid",
'int');
752 if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
753 reset($object->socpeopleassigned);
754 $object->contact_id = key($object->socpeopleassigned);
756 $object->fk_project =
GETPOST(
"projectid",
'int');
757 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
759 if (
GETPOST(
"elementtype",
'alpha')) {
760 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
762 $hasPermissionOnLinkedObject = 0;
763 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
764 $hasPermissionOnLinkedObject = 1;
766 if ($hasPermissionOnLinkedObject) {
767 $object->fk_element =
GETPOST(
"fk_element",
'int');
768 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
772 if (!$datef && $percentage == 100) {
773 $error++; $donotclearsession = 1;
774 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), $object->errors,
'errors');
778 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
781 $listofuserid = array();
782 if (!empty($_SESSION[
'assignedtouser'])) {
784 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
785 foreach ($tmplist1 as $key => $val) {
786 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
787 $listofuserid[$val[
'id']] = $val;
791 $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
792 if ($assignedtouser) {
793 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>($user->id == $assignedtouser ? $transparency :
''));
796 $object->userassigned = array(); $object->userownerid = 0;
798 foreach ($listofuserid as $key => $val) {
800 $object->userownerid = $val[
'id'];
802 $object->userassigned[$val[
'id']] = array(
'id'=>$val[
'id'],
'mandatory'=>0,
'transparency'=>($user->id == $val[
'id'] ? $transparency :
''));
806 $object->transparency = $transparency;
809 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
811 $object->userdoneid =
GETPOST(
"doneby",
"int");
817 $error++; $donotclearsession = 1;
819 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
821 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
823 if (empty($object->userownerid)) {
824 $error++; $donotclearsession = 1;
826 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
830 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
837 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
838 $eventDateStart = $object->datep;
839 $eventDateEnd = $object->datef;
841 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
842 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
843 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
844 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
845 $sql .=
" WHERE ac.id <> ".((int) $object->id);
846 $sql .=
" AND er.resource_id IN (";
847 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
848 $sql .=
" WHERE element_id = ".((int) $object->id);
849 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
850 $sql .=
" AND busy = 1";
852 $sql .=
" AND er.busy = 1";
856 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
858 if (!empty($eventDateEnd)) {
859 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
863 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
864 if (!empty($eventDateEnd)) {
865 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
870 $resql = $db->query($sql);
873 $object->error = $db->lasterror();
874 $object->errors[] = $object->error;
876 if ($db->num_rows(
$resql) > 0) {
879 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
880 while ($obj = $db->fetch_object(
$resql)) {
881 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
883 $object->errors[] = $object->error;
897 $result = $object->update($user);
901 $categories =
GETPOST(
'categories',
'array');
902 $object->setCategories($categories);
904 $object->loadReminders($remindertype, 0,
false);
905 if (!empty($object->reminders) && $object->datep >
dol_now()) {
906 foreach ($object->reminders as $reminder) {
907 $reminder->delete($user);
909 $object->reminders = array();
913 if ($addreminder ==
'on' && $object->datep >
dol_now()) {
918 $actionCommReminder->dateremind = $dateremind;
919 $actionCommReminder->typeremind = $remindertype;
920 $actionCommReminder->offsetunit = $offsetunit;
921 $actionCommReminder->offsetvalue = $offsetvalue;
922 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
923 $actionCommReminder->fk_actioncomm = $object->id;
924 if ($remindertype ==
'email') {
925 $actionCommReminder->fk_email_template = $modelmail;
929 foreach ($object->userassigned as $userassigned) {
930 $actionCommReminder->fk_user = $userassigned[
'id'];
931 $res = $actionCommReminder->create($user);
935 $langs->load(
"errors");
936 $error = $langs->trans(
'ErrorReminderActionCommCreation');
938 $action =
'create'; $donotclearsession = 1;
944 unset($_SESSION[
'assignedtouser']);
959 if (!empty($backtopage)) {
960 unset($_SESSION[
'assignedtouser']);
961 header(
"Location: ".$backtopage);
968 if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
970 $object->fetch_optionals();
971 $object->fetch_userassigned();
974 if ($user->rights->agenda->myactions->delete
975 || $user->rights->agenda->allactions->delete) {
976 $result = $object->delete();
979 header(
"Location: index.php");
991 if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
997 $newdate =
GETPOST(
'newdate',
'alpha');
998 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
999 header(
"Location: ".$backtopage,
true, 307);
1003 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
1006 if ($datep != $object->datep) {
1007 if (!empty($object->datef)) {
1008 $object->datef += $datep - $object->datep;
1010 $object->datep = $datep;
1014 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
1015 $eventDateStart = $object->datep;
1016 $eventDateEnd = $object->datef;
1018 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1019 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1020 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1021 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
1022 $sql .=
" WHERE ac.id <> ".((int) $object->id);
1023 $sql .=
" AND er.resource_id IN (";
1024 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1025 $sql .=
" WHERE element_id = ".((int) $object->id);
1026 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
1027 $sql .=
" AND busy = 1";
1029 $sql .=
" AND er.busy = 1";
1033 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1035 if (!empty($eventDateEnd)) {
1036 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1040 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1041 if (!empty($eventDateEnd)) {
1042 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1047 $resql = $db->query($sql);
1050 $object->error = $db->lasterror();
1051 $object->errors[] = $object->error;
1053 if ($db->num_rows(
$resql) > 0) {
1056 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1057 while ($obj = $db->fetch_object(
$resql)) {
1058 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1060 $object->errors[] = $object->error;
1073 $result = $object->update($user);
1083 if (!empty($backtopage)) {
1084 header(
"Location: ".$backtopage,
true, 307);
1093 $permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read));
1094 if (empty($reshook)) {
1095 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1106 $arrayrecurrulefreq = array(
1107 'no'=>$langs->trans(
"OnceOnly"),
1108 'MONTHLY'=>$langs->trans(
"EveryMonth"),
1109 'WEEKLY'=>$langs->trans(
"EveryWeek")
1114 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
1117 if ($action ==
'create') {
1120 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1121 if (!empty($socpeopleassigned[0])) {
1122 $result = $contact->fetch($socpeopleassigned[0]);
1130 if (!empty($conf->use_javascript_ajax)) {
1131 print
"\n".
'<script type="text/javascript">';
1132 print
'$(document).ready(function () {
1133 function setdatefields()
1135 if ($("#fullday:checked").val() == null) {
1136 $(".fulldaystarthour").removeAttr("disabled");
1137 $(".fulldaystartmin").removeAttr("disabled");
1138 $(".fulldayendhour").removeAttr("disabled");
1139 $(".fulldayendmin").removeAttr("disabled");
1140 $("#p2").removeAttr("disabled");
1142 $(".fulldaystarthour").prop("disabled", true).val("00");
1143 $(".fulldaystartmin").prop("disabled", true).val("00");
1144 $(".fulldayendhour").prop("disabled", true).val("23");
1145 $(".fulldayendmin").prop("disabled", true).val("59");
1146 $("#p2").removeAttr("disabled");
1149 $("#fullday").change(function() {
1150 console.log("setdatefields");
1154 $("#selectcomplete").change(function() {
1155 console.log("we change the complete status - set the doneby");
1156 if ($("#selectcomplete").val() == 100) {
1157 if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).
'\');
1159 if ($(
"#selectcomplete").val() == 0) {
1160 $(
"#doneby").val(-1);
1164 $(
"#actioncode").change(
function() {
1165 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
1166 else $("#dateend").removeClass("fieldrequired");
1168 $("#aphour,#apmin").change(function() {
1169 if ($("#actioncode").val() == \'AC_RDV\') {
1170 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1171 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1172 $("#p2min").val($("#apmin").val());
1173 $("#p2day").val($("#apday").val());
1174 $("#p2month").val($("#apmonth").val());
1175 $("#p2year").val($("#apyear").val());
1176 $("#p2").val($("#ap").val());
1179 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1180 else $("#dateend").removeClass("fieldrequired");
1183 print
'</script>'.
"\n";
1186 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1187 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1188 print
'<input type="hidden" name="action" value="add">';
1189 print
'<input type="hidden" name="donotclearsession" value="1">';
1190 print
'<input type="hidden" name="page_y" value="">';
1192 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1194 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1195 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1198 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1199 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1206 print
'<table class="border centpercent">';
1209 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1210 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1212 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1213 $selectedvalue =
GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : ($object->type_code ? $object->type_code : $default);
1214 print
$formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1219 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>';
1222 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>';
1225 $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1226 if ($userepeatevent) {
1229 print
' <div class="opacitymedium inline-block">';
1230 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1231 print
'<input type="hidden" name="recurid" value="'.(empty($object->recurid) ?
'' : $object->recurid).
'">';
1233 $selectedrecurrulefreq =
'no';
1234 $selectedrecurrulebymonthday =
'';
1235 $selectedrecurrulebyday =
'';
1236 $object->recurrule =
GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1237 $object->recurrule .=
GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1238 $object->recurrule .=
GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1242 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1243 $selectedrecurrulefreq = $reg[1];
1245 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) {
1246 $selectedrecurrulebymonthday = $reg[1];
1248 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1249 $selectedrecurrulebyday = $reg[1];
1252 print
$form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1258 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1259 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1262 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1263 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1266 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1267 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1268 print $langs->trans(
"Until").
" ";
1269 print
$form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1272 print
'<script type="text/javascript">
1273 jQuery(document).ready(function() {
1274 function init_repeat()
1276 console.log("recurrule: " + "'.$object->recurrule.
'");
1277 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1278 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1279 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1280 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1281 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1283 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1284 jQuery(".repeateventlimitdate").css("display", "inline-block");
1285 jQuery(".repeateventBYDAY").hide();
1287 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1289 jQuery(".repeateventBYMONTHDAY").hide();
1290 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1291 jQuery(".repeateventlimitdate").css("display", "inline-block");
1295 jQuery(".repeateventBYMONTHDAY").hide();
1296 jQuery(".repeateventBYDAY").hide();
1297 jQuery(".repeateventlimitdate").hide();
1301 jQuery("#recurrulefreq").change(function() {
1312 $datep = ($datep ? $datep : (is_null($object->datep) ?
'' : $object->datep));
1313 if (
GETPOST(
'datep',
'int', 1)) {
1316 $datef = ($datef ? $datef : $object->datef);
1317 if (
GETPOST(
'datef',
'int', 1)) {
1320 if (empty($datef) && !empty($datep)) {
1321 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
1322 $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');
1327 print
'<tr><td class="nowrap">';
1330 print
$form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1332 print
$form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1334 print
' <span class="hideonsmartphone"> - </span> ';
1336 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1338 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1342 print
'<tr><td class=""> </td><td></td></tr>';
1345 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1346 $listofuserid = array();
1347 $listofcontactid = array();
1348 $listofotherid = array();
1350 if (empty($donotclearsession)) {
1351 $assignedtouser =
GETPOST(
"assignedtouser") ?
GETPOST(
"assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1352 if ($assignedtouser) {
1353 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>$object->transparency);
1356 $listofuserid[$assignedtouser][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1357 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1359 if (!empty($_SESSION[
'assignedtouser'])) {
1360 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1362 $firstelem = reset($listofuserid);
1363 if (isset($listofuserid[$firstelem[
'id']])) {
1364 $listofuserid[$firstelem[
'id']][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1367 print
'<div class="assignedtouser">';
1368 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1373 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1374 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1375 print
$form->select_dolusers(
GETPOSTISSET(
"doneby") ?
GETPOST(
"doneby",
'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0),
'doneby', 1);
1380 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1381 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>';
1385 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1387 $percent = $complete !==
'' ? $complete : -1;
1391 $percent =
GETPOST(
'percentage',
'int');
1393 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1395 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1399 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1404 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1405 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1406 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1413 print
'<br><hr><br>';
1416 print
'<table class="border centpercent">';
1420 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1421 if (
GETPOST(
'socid',
'int') > 0) {
1423 $societe->fetch(
GETPOST(
'socid',
'int'));
1424 print $societe->getNomUrl(1);
1425 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOST(
'socid',
'int').
'">';
1428 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1430 if (!empty($user->socid)) {
1431 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300');
1433 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
1439 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1440 $preselectedids =
GETPOST(
'socpeopleassigned',
'array');
1441 if (
GETPOST(
'contactid',
'int')) {
1442 $preselectedids[
GETPOST(
'contactid',
'int')] =
GETPOST(
'contactid',
'int');
1444 if ($origin==
'contact') $preselectedids[
GETPOST(
'originid',
'int')] =
GETPOST(
'originid',
'int');
1445 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1446 print
$form->selectcontacts(
GETPOST(
'socid',
'int'), $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 quatrevingtpercent',
false, 0, array(),
false,
'multiple',
'contactid');
1452 $langs->load(
"projects");
1454 $projectid =
GETPOST(
'projectid',
'int');
1456 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1457 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1458 print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
1460 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1461 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1462 $urloption =
'?action=create&donotclearsession=1';
1466 print
"\n".
'<script type="text/javascript">';
1467 print
'$(document).ready(function () {
1468 $("#projectid").change(function () {
1469 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1470 console.log("Call url to get new list of tasks: "+url);
1471 $.get(url, function(data) {
1473 if (data) $("#taskid").html(data).select2();
1477 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', $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;">';
1557 print
'<table class="border centpercent">';
1560 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1561 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOST(
'offsetvalue',
'int') :
'15').
'"> ';
1562 print
$form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1566 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1567 print
$form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1572 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1573 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1580 print
"\n".
'<script type="text/javascript">';
1581 print
'$(document).ready(function () {
1582 $("#addreminder").click(function(){
1583 console.log("Click on addreminder");
1585 $(".reminderparameters").show();
1587 $(".reminderparameters").hide();
1589 $("#selectremindertype").select2("destroy");
1590 $("#selectremindertype").select2();
1591 $("#select_offsetunittype_duration").select2("destroy");
1592 $("#select_offsetunittype_duration").select2();
1595 $("#selectremindertype").change(function(){
1596 console.log("Change on selectremindertype");
1597 var selected_option = $("#selectremindertype option:selected").val();
1598 if(selected_option == "email") {
1599 $("#select_actioncommsendmodel_mail").closest("tr").show();
1601 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1605 print
'</script>'.
"\n";
1610 print
$form->buttonsSaveCancel(
"Add");
1617 $result1 = $object->fetch($id);
1618 if ($result1 <= 0) {
1619 $langs->load(
"errors");
1620 print $langs->trans(
"ErrorRecordNotFound");
1626 $result2 = $object->fetch_thirdparty();
1627 $result2 = $object->fetch_projet();
1628 $result3 = $object->fetch_contact();
1629 $result4 = $object->fetch_userassigned();
1630 $result5 = $object->fetch_optionals();
1632 if ($listUserAssignedUpdated || $donotclearsession) {
1633 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
1635 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
1636 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
1639 $object->label =
GETPOST(
"label",
"alphanohtml");
1640 $object->datep = $datep;
1641 $object->datef = $datef;
1642 $object->percentage = $percentage;
1643 $object->priority =
GETPOST(
"priority",
"alphanohtml");
1644 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
1645 $object->location =
GETPOST(
'location',
"alpanohtml");
1646 $object->socid =
GETPOST(
"socid",
"int");
1647 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1648 foreach ($socpeopleassigned as $tmpid) {
1649 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1651 $object->contact_id =
GETPOST(
"contactid",
'int');
1652 $object->fk_project =
GETPOST(
"projectid",
'int');
1654 $object->note_private =
GETPOST(
"note",
'restricthtml');
1657 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1662 if ($object->authorid > 0) {
1663 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
1665 if ($object->usermodid > 0) {
1666 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
1677 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1681 if ($action ==
'delete') {
1682 print
$form->formconfirm(
"card.php?id=".urlencode($id), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1685 if ($action ==
'edit') {
1686 if (!empty($conf->use_javascript_ajax)) {
1687 print
"\n".
'<script type="text/javascript">';
1688 print
'$(document).ready(function () {
1689 function setdatefields()
1691 if ($("#fullday:checked").val() == null) {
1692 $(".fulldaystarthour").removeAttr("disabled");
1693 $(".fulldaystartmin").removeAttr("disabled");
1694 $(".fulldayendhour").removeAttr("disabled");
1695 $(".fulldayendmin").removeAttr("disabled");
1697 $(".fulldaystarthour").prop("disabled", true).val("00");
1698 $(".fulldaystartmin").prop("disabled", true).val("00");
1699 $(".fulldayendhour").prop("disabled", true).val("23");
1700 $(".fulldayendmin").prop("disabled", true).val("59");
1704 $("#fullday").change(function() {
1707 $("#actioncode").change(function() {
1708 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1709 else $("#dateend").removeClass("fieldrequired");
1712 print
'</script>'.
"\n";
1715 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1716 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1717 print
'<input type="hidden" name="action" value="update">';
1718 print
'<input type="hidden" name="id" value="'.$id.
'">';
1719 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1720 print
'<input type="hidden" name="page_y" value="">';
1722 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1724 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code)) {
1725 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1730 print
'<table class="border tableforfield" width="100%">';
1733 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.$object->id.
'</td></tr>';
1736 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->elementtype !=
"ticket") {
1737 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1738 if ($object->type_code !=
'AC_OTH_AUTO') {
1739 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1740 print
$formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') : $object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1742 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1743 print $object->getTypePicto();
1744 print $langs->trans(
"Action".$object->type_code);
1750 if ($object->elementtype ==
'ticket') {
1751 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
1752 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1753 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code) ?
' checked' :
'').
'></td></tr>';
1757 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>';
1760 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' :
'').
'>';
1761 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1824 print
'<tr><td class="nowrap">';
1829 print
'</td><td td colspan="3">';
1832 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 0,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1833 } elseif (
GETPOST(
"afaire") == 2) {
1834 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1836 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1838 print
' <span class="hideonsmartphone"> - </span> ';
1840 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1841 } elseif (
GETPOST(
"afaire") == 2) {
1842 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1844 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1848 print
'<tr><td class=""> </td><td></td></tr>';
1851 $listofuserid = array();
1852 if (empty($donotclearsession)) {
1853 if ($object->userownerid > 0) {
1854 $listofuserid[$object->userownerid] = array(
1855 'id'=>$object->userownerid,
1858 'transparency'=>$object->transparency,
1859 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
1860 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
1863 if (!empty($object->userassigned)) {
1865 $tmplist1 = $object->userassigned;
1866 foreach ($tmplist1 as $key => $val) {
1867 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
1868 $listofuserid[$val[
'id']] = $val;
1872 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1874 if (!empty($_SESSION[
'assignedtouser'])) {
1875 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1878 $listofcontactid = $object->socpeopleassigned;
1879 $listofotherid = $object->otherassigned;
1881 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
1882 print
'<div class="assignedtouser">';
1883 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1894 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1895 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td colspan="3">';
1896 print
$form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1,
'doneby', 1);
1901 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1902 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
1906 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
1907 $percent =
GETPOSTISSET(
"percentage") ?
GETPOST(
"percentage",
"int") : $object->percentage;
1908 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1913 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1914 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1916 $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
1917 $arrayselected = array();
1918 foreach ($cats as $cat) {
1919 $arrayselected[] = $cat->id;
1921 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1928 print
'<br><hr><br>';
1931 print
'<table class="border tableforfield centpercent">';
1935 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
1937 print
'<div class="maxwidth200onsmartphone">';
1939 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1942 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth200');
1947 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
1948 print
'<div class="maxwidth200onsmartphone">';
1949 print
img_picto(
'',
'contact',
'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'quatrevingtpercent',
false, 0, 0, array(),
'multiple',
'contactid');
1957 $langs->load(
"projects");
1959 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
1960 print
img_picto(
'',
'project',
'class="paddingrightonly"');
1961 $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth500');
1962 if ($numprojet == 0) {
1963 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>';
1969 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1970 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
1971 print
'<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
1976 if (!empty($object->fk_element) && !empty($object->elementtype)) {
1977 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1979 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
1981 if ($object->elementtype ==
'task' &&
isModEnabled(
'project')) {
1982 print
'<td id="project-task-input-container" >';
1984 $urloption =
'?action=create&donotclearsession=1';
1985 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
1988 print
"\n".
'<script type="text/javascript" >';
1989 print
'$(document).ready(function () {
1990 $("#projectid").change(function () {
1991 var url = "'.$url.
'&projectid="+$("#projectid").val();
1992 $.get(url, function(data) {
1993 console.log($( data ).find("#fk_element").html());
1994 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
1998 print
'</script>'.
"\n";
2000 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
2001 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2007 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2008 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2016 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2018 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2019 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, $conf->fckeditor->enabled, ROWS_4,
'90%');
2020 $doleditor->Create();
2025 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
2026 print $hookmanager->resPrint;
2027 if (empty($reshook)) {
2028 print $object->showOptionals($extrafields,
'edit',
$parameters);
2035 $filteruserid = $user->id;
2036 if ($user->rights->agenda->allactions->read) {
2039 $object->loadReminders(
'', $filteruserid,
false);
2043 if (count($object->reminders) > 0) {
2044 $checked =
'checked';
2045 $keys = array_keys($object->reminders);
2046 $firstreminderId = array_shift($keys);
2048 $actionCommReminder = $object->reminders[$firstreminderId];
2052 $actionCommReminder->offsetvalue = 10;
2053 $actionCommReminder->offsetunit =
'i';
2054 $actionCommReminder->typeremind =
'email';
2057 print
'<label for="addreminder">'.$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder" '.$checked.
'><br>';
2059 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2063 print
'<table class="border centpercent">';
2066 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2067 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2068 print
$form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2072 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2073 print
$form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2077 if ($actionCommReminder->typeremind ==
'browser') {
2078 $hide =
'style="display:none;"';
2082 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2083 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2088 print
"\n".
'<script type="text/javascript">';
2089 print
'$(document).ready(function () {
2090 $("#addreminder").click(function(){
2092 $(".reminderparameters").show();
2094 $(".reminderparameters").hide();
2098 $("#selectremindertype").change(function(){
2099 var selected_option = $("#selectremindertype option:selected").val();
2100 if(selected_option == "email") {
2101 $("#select_actioncommsendmodel_mail").closest("tr").show();
2103 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2108 print
'</script>'.
"\n";
2115 print
$form->buttonsSaveCancel();
2124 if ($action ==
'clone') {
2125 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', array(),
'yes', 1);
2130 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2131 if (empty($reshook))
$formconfirm.=$hookmanager->resPrint;
2132 elseif ($reshook > 0)
$formconfirm=$hookmanager->resPrint;
2139 $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2140 $linkback .=
img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"');
2141 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("BackToList").'</span>';
2142 $linkback .= '</a>';
2143 $linkback .= '</li>';
2144 $linkback .= '<li class="noborder litext">';
2145 $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').'">';
2146 $linkback .=
img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"');
2147 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewCal").'</span>';
2148 $linkback .= '</a>';
2149 $linkback .= '</li>';
2150 $linkback .= '<li class="noborder litext">';
2151 $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').'">';
2152 $linkback .=
img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"');
2153 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewWeek").'</span>';
2154 $linkback .= '</a>';
2155 $linkback .= '</li>';
2156 $linkback .= '<li class="noborder litext">';
2157 $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').'">';
2158 $linkback .=
img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"');
2159 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewDay").'</span>';
2160 $linkback .= '</a>';
2161 $linkback .= '</li>';
2162 $linkback .= '<li class="noborder litext">';
2163 $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').'">';
2164 $linkback .=
img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"');
2165 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewPerUser").'</span>';
2166 $linkback .= '</a>';
2170 $reshook = $hookmanager->executeHooks('addCalendarView',
$parameters, $object, $action);
2171 if (empty($reshook)) {
2172 $linkback .= $hookmanager->resPrint;
2173 } elseif ($reshook > 1) {
2174 $linkback = $hookmanager->resPrint;
2179 $morehtmlref =
'<div class="refidno">';
2184 $langs->load(
"projects");
2186 if ($usercancreate) {
2187 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2188 if ($action !=
'classify') {
2189 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2191 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2193 if (!empty($object->fk_project)) {
2195 $proj->fetch($object->fk_project);
2196 $morehtmlref .= $proj->getNomUrl(1);
2198 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2203 $morehtmlref .=
'</div>';
2206 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2208 print
'<div class="fichecenter">';
2209 print
'<div class="fichehalfleft">';
2211 print
'<div class="underbanner clearboth"></div>';
2214 print
'<table class="border tableforfield" width="100%">';
2217 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
2218 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2219 print $object->getTypePicto();
2220 print $langs->trans(
"Action".$object->type_code);
2225 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2228 if ($object->recurid) {
2229 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag($object->recurid).
'</td></tr>';
2233 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2238 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2243 if (empty($object->fulldayevent)) {
2247 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2249 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2256 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2257 if (empty($object->fulldayevent)) {
2261 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2263 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2269 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2270 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
2274 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2275 $listofuserid = array();
2276 if (empty($donotclearsession)) {
2277 if ($object->userownerid > 0) {
2278 $listofuserid[$object->userownerid] = array(
2279 'id'=>$object->userownerid,
2280 'transparency'=>$object->transparency,
2281 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2282 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2285 if (!empty($object->userassigned)) {
2287 $tmplist1 = $object->userassigned;
2288 foreach ($tmplist1 as $key => $val) {
2289 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2290 $listofuserid[$val[
'id']] = $val;
2294 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2296 if (!empty($_SESSION[
'assignedtouser'])) {
2297 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2301 $listofcontactid = array();
2302 $listofotherid = array();
2303 print
'<div class="assignedtouser">';
2304 print
$form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2314 print
' </td></tr>';
2317 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
2318 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
2319 if ($object->userdoneid > 0) {
2320 $tmpuser =
new User($db);
2321 $tmpuser->fetch($object->userdoneid);
2322 print $tmpuser->getNomUrl(1);
2329 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2330 print
$form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2338 print
'<div class="fichehalfright">';
2340 print
'<div class="underbanner clearboth"></div>';
2341 print
'<table class="border tableforfield centpercent">';
2345 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2346 print
'<td>'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2347 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL') {
2348 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2349 print
"<br>".dol_print_phone($object->thirdparty->phone);
2355 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2358 if (!empty($object->socpeopleassigned)) {
2359 foreach ($object->socpeopleassigned as $cid => $Tab) {
2361 $result = $contact->fetch($cid);
2368 print $contact->getNomUrl(1);
2369 if ($object->type_code ==
'AC_TEL') {
2370 if (!empty($contact->phone_pro)) {
2371 print
'('.dol_print_phone($contact->phone_pro).
')';
2374 print
'<div class="paddingright"></div>';
2378 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2384 print
'<tr><td class="nowrap" class="titlefield">'.$langs->trans(
"Priority").
'</td><td>';
2385 print ($object->priority ? $object->priority :
'');
2390 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project'))) {
2391 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2392 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2396 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2404 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
2409 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2412 if (!empty($conf->global->AGENDA_REMINDER_EMAIL) || !empty($conf->global->AGENDA_REMINDER_BROWSER)) {
2413 $filteruserid = $user->id;
2414 if ($user->rights->agenda->allactions->read) {
2417 $object->loadReminders(
'', $filteruserid,
false);
2419 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2421 if (count($object->reminders) > 0) {
2422 $tmpuserstatic =
new User($db);
2424 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2425 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2426 if ($actioncommreminder->fk_user > 0) {
2427 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2428 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2430 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2431 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2432 print
' - <span class="opacitymedium">';
2433 print $langs->trans(
"NotSent");
2435 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2436 print
' - <span class="opacitymedium">';
2437 print $langs->trans(
"Done");
2451 print
'<div class="clearboth"></div>';
2460 print
'<div class="tabsAction">';
2463 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2464 if (empty($reshook)) {
2465 if ($action !=
'edit') {
2466 if ($user->rights->agenda->allactions->create ||
2467 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2468 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2470 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2473 if ($user->rights->agenda->allactions->create ||
2474 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2475 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>';
2477 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2480 if ($user->rights->agenda->allactions->delete ||
2481 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) {
2482 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2484 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2491 if ($action !=
'edit') {
2492 if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) {
2493 print
'<div style="clear:both;"></div><div class="fichecenter"><div class="fichehalfleft">';
2494 print
'<a name="builddoc"></a>';
2500 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2501 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2503 $genallowed = $user->rights->agenda->myactions->read;
2504 $delallowed = $user->rights->agenda->myactions->create;
2507 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2509 print
'</div><div class="fichehalfright">';
2512 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') &&!empty($user->rights->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') &&!empty($user->rights->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)) $resql
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_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 =...
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array())
Clean a string to keep only desirable HTML tags.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...
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.
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.