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');
106 $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');
158 if ($user->socid && $socid) {
162 $usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create);
169 $listUserAssignedUpdated =
false;
171 if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
172 $idtoremove =
GETPOST(
'removedassigned');
174 if (!empty($_SESSION[
'assignedtouser'])) {
175 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'], 1);
177 $tmpassigneduserids = array();
180 foreach ($tmpassigneduserids as $key => $val) {
181 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
182 unset($tmpassigneduserids[$key]);
186 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
187 $donotclearsession = 1;
188 if ($action ==
'add') {
191 if ($action ==
'update') {
195 $listUserAssignedUpdated =
true;
199 if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
201 if (
GETPOST(
'assignedtouser') > 0) {
202 $assignedtouser = array();
203 if (!empty($_SESSION[
'assignedtouser'])) {
204 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
206 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id'=>
GETPOST(
'assignedtouser'),
'transparency'=>
GETPOST(
'transparency'),
'mandatory'=>1);
207 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
209 $donotclearsession = 1;
210 if ($action ==
'add') {
213 if ($action ==
'update') {
217 $listUserAssignedUpdated =
true;
221 if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
222 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) {
224 $object->setProject(
GETPOST(
'projectid',
'int'));
228 if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes') {
229 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
234 if (!empty($object->socpeopleassigned)) {
235 reset($object->socpeopleassigned);
236 $object->contact_id = key($object->socpeopleassigned);
238 $result = $object->createFromClone($user,
GETPOST(
'socid',
'int'));
240 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
251 if (empty($reshook) && $action ==
'add') {
254 if (empty($backtopage)) {
256 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
258 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
262 if (!empty($socpeopleassigned[0])) {
263 $result = $contact->fetch($socpeopleassigned[0]);
267 header(
"Location: ".$backtopage);
271 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
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'), $tzforfullday ? $tzforfullday :
'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'), $tzforfullday ? $tzforfullday :
'tzuser');
280 $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');
281 $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');
285 if (!$datef && $percentage == 100) {
286 $error++; $donotclearsession = 1;
288 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
291 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !
GETPOST(
'label')) {
292 $error++; $donotclearsession = 1;
294 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
299 $error++; $donotclearsession = 1;
301 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
303 $object->type_code =
GETPOST(
'actioncode',
'aZ09');
309 $object->fulldayevent = ($fulldayevent ? 1 : 0);
310 $object->location =
GETPOST(
"location",
'alphanohtml');
311 $object->label =
GETPOST(
'label',
'alphanohtml');
313 if (
GETPOST(
"elementtype",
'alpha')) {
314 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
316 $hasPermissionOnLinkedObject = 0;
317 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
318 $hasPermissionOnLinkedObject = 1;
320 if ($hasPermissionOnLinkedObject) {
321 $object->fk_element =
GETPOST(
"fk_element",
'int');
322 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
327 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
328 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
330 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
331 $object->label = $langs->transnoentitiesnoconv(
"Action".$object->type_code).
"\n";
333 $cactioncomm->fetch($object->type_code);
334 $object->label = $cactioncomm->label;
340 $taskid =
GETPOST(
'taskid',
'int');
341 if (!empty($taskid)) {
342 $taskProject =
new Task($db);
343 if ($taskProject->fetch($taskid) > 0) {
344 $object->fk_project = $taskProject->fk_project;
347 $object->fk_element = $taskid;
348 $object->elementtype =
'task';
351 $object->datep = $datep;
352 $object->datef = $datef;
353 $object->percentage = $percentage;
354 $object->duree = (((int)
GETPOST(
'dureehour') * 60) + (
int)
GETPOST(
'dureemin')) * 60;
356 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
358 $listofuserid = array();
359 if (!empty($_SESSION[
'assignedtouser'])) {
360 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
363 foreach ($listofuserid as $key => $value) {
365 if ($value[
'id'] > 0) {
366 $object->userownerid = $value[
'id'];
368 $object->transparency = $transparency;
371 $object->userassigned[$value[
'id']] = array(
'id'=>$value[
'id'],
'transparency'=>$transparency);
377 if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) {
379 $object->userdoneid =
GETPOST(
"doneby",
"int");
383 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
386 $object->contact = $contact;
389 if (
GETPOST(
'socid',
'int') > 0) {
390 $object->socid =
GETPOST(
'socid',
'int');
391 $object->fetch_thirdparty();
393 $object->societe = $object->thirdparty;
397 if (empty($object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
398 $error++; $donotclearsession = 1;
400 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
402 if ($object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
403 $error++; $donotclearsession = 1;
405 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
409 $error++; $donotclearsession = 1;
411 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
414 foreach ($socpeopleassigned as $cid) {
415 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
417 if (!empty($object->socpeopleassigned)) {
418 reset($object->socpeopleassigned);
419 $object->contact_id = key($object->socpeopleassigned);
423 $ret = $extrafields->setOptionalsFromPost(
null, $object);
433 $selectedrecurrulefreq =
'no';
434 $selectedrecurrulebymonthday =
'';
435 $selectedrecurrulebyday =
'';
436 $object->recurrule =
GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
437 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' &&
GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
438 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' &&
GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
440 $reg1 = array(); $reg2 = array(); $reg3 = array();
441 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) {
442 $selectedrecurrulefreq = $reg1[1];
444 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) {
445 $selectedrecurrulebymonthday = $reg2[1];
447 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) {
448 $selectedrecurrulebyday = $reg3[1];
452 $eventisrecurring = 0;
453 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
454 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
455 $eventisrecurring = 1;
459 unset($object->recurid);
460 unset($object->recurrule);
461 unset($object->recurdateend);
465 $idaction = $object->create($user);
468 if (!$object->error) {
470 $categories =
GETPOST(
'categories',
'array');
471 $object->setCategories($categories);
473 unset($_SESSION[
'assignedtouser']);
476 if ($user->id != $object->userownerid) {
477 $moreparam =
"filtert=-1";
481 if ($addreminder ==
'on') {
486 $actionCommReminder->dateremind = $dateremind;
487 $actionCommReminder->typeremind = $remindertype;
488 $actionCommReminder->offsetunit = $offsetunit;
489 $actionCommReminder->offsetvalue = $offsetvalue;
490 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
491 $actionCommReminder->fk_actioncomm = $object->id;
492 if ($remindertype ==
'email') {
493 $actionCommReminder->fk_email_template = $modelmail;
497 foreach ($object->userassigned as $userassigned) {
498 $actionCommReminder->fk_user = $userassigned[
'id'];
499 $res = $actionCommReminder->create($user);
504 $langs->load(
"errors");
505 $error = $langs->trans(
'ErrorReminderActionCommCreation');
507 $action =
'create'; $donotclearsession = 1;
518 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
538 $langs->load(
"errors");
539 $error = $langs->trans($object->error);
541 $action =
'create'; $donotclearsession = 1;
546 $action =
'create'; $donotclearsession = 1;
549 if ($eventisrecurring) {
551 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
553 $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');
557 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
558 $firstday = $selectedrecurrulebymonthday;
559 $firstmonth =
GETPOST(
"apday") > $selectedrecurrulebymonthday ?
GETPOST(
"apmonth",
'int') + 1 :
GETPOST(
"apmonth",
'int');
560 $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');
567 $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');
572 while ($datep <= $repeateventlimitdate && !$error) {
573 $finalobject = clone $object;
576 $finalobject->datep = $datep;
577 $finalobject->datef = $datef;
579 $idaction = $finalobject->create($user);
582 if (!$finalobject->error) {
584 $categories =
GETPOST(
'categories',
'array');
585 $finalobject->setCategories($categories);
587 unset($_SESSION[
'assignedtouser']);
590 if ($user->id != $finalobject->userownerid) {
591 $moreparam =
"filtert=-1";
595 if ($addreminder ==
'on') {
600 $actionCommReminder->dateremind = $dateremind;
601 $actionCommReminder->typeremind = $remindertype;
602 $actionCommReminder->offsetunit = $offsetunit;
603 $actionCommReminder->offsetvalue = $offsetvalue;
604 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
605 $actionCommReminder->fk_actioncomm = $finalobject->id;
606 if ($remindertype ==
'email') {
607 $actionCommReminder->fk_email_template = $modelmail;
611 foreach ($finalobject->userassigned as $userassigned) {
612 $actionCommReminder->fk_user = $userassigned[
'id'];
613 $res = $actionCommReminder->create($user);
618 $langs->load(
"errors");
619 $error = $langs->trans(
'ErrorReminderActionCommCreation');
621 $action =
'create'; $donotclearsession = 1;
632 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
642 $langs->load(
"errors");
643 $error = $langs->trans($finalobject->error);
645 $action =
'create'; $donotclearsession = 1;
650 $action =
'create'; $donotclearsession = 1;
665 if (!empty($backtopage) && !$error) {
666 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
667 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
668 } elseif ($idaction) {
669 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
671 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
680 if (empty($reshook) && $action ==
'update') {
681 if (empty($cancel)) {
682 $fulldayevent =
GETPOST(
'fullday');
683 $aphour =
GETPOST(
'aphour',
'int');
684 $apmin =
GETPOST(
'apmin',
'int');
685 $p2hour =
GETPOST(
'p2hour',
'int');
686 $p2min =
GETPOST(
'p2min',
'int');
687 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
704 $object->fetch_optionals();
705 $object->fetch_userassigned();
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'), $tzforfullday ? $tzforfullday :
'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'), $tzforfullday ? $tzforfullday :
'tzuser');
715 $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');
716 $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');
719 if ($object->elementtype ==
'ticket') {
721 if ($object->code ==
'TICKET_MSG') {
722 $object->code =
'TICKET_MSG_PRIVATE';
724 if ($object->code ==
'TICKET_MSG_SENTBYMAIL') {
725 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
728 if ($object->code ==
'TICKET_MSG_PRIVATE') {
729 $object->code =
'TICKET_MSG';
731 if ($object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
732 $object->code =
'TICKET_MSG_SENTBYMAIL';
738 $object->type_code =
GETPOST(
"actioncode",
'aZ09');
741 $object->label =
GETPOST(
"label",
"alphanohtml");
742 $object->datep = $datep;
743 $object->datef = $datef;
744 $object->percentage = $percentage;
745 $object->priority =
GETPOST(
"priority",
"int");
746 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
747 $object->location =
GETPOST(
'location',
"alphanohtml");
748 $object->socid =
GETPOST(
"socid",
"int");
749 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
750 $object->socpeopleassigned = array();
751 foreach ($socpeopleassigned as $cid) {
752 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
754 $object->contact_id =
GETPOST(
"contactid",
'int');
755 if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
756 reset($object->socpeopleassigned);
757 $object->contact_id = key($object->socpeopleassigned);
759 $object->fk_project =
GETPOST(
"projectid",
'int');
760 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
762 if (
GETPOST(
"elementtype",
'alpha')) {
763 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
765 $hasPermissionOnLinkedObject = 0;
766 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
767 $hasPermissionOnLinkedObject = 1;
769 if ($hasPermissionOnLinkedObject) {
770 $object->fk_element =
GETPOST(
"fk_element",
'int');
771 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
775 if (!$datef && $percentage == 100) {
776 $error++; $donotclearsession = 1;
777 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), $object->errors,
'errors');
781 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
784 $listofuserid = array();
785 if (!empty($_SESSION[
'assignedtouser'])) {
787 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
788 foreach ($tmplist1 as $key => $val) {
789 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
790 $listofuserid[$val[
'id']] = $val;
794 $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
795 if ($assignedtouser) {
796 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>($user->id == $assignedtouser ? $transparency :
''));
799 $object->userassigned = array(); $object->userownerid = 0;
801 foreach ($listofuserid as $key => $val) {
803 $object->userownerid = $val[
'id'];
805 $object->userassigned[$val[
'id']] = array(
'id'=>$val[
'id'],
'mandatory'=>0,
'transparency'=>($user->id == $val[
'id'] ? $transparency :
''));
809 $object->transparency = $transparency;
812 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
814 $object->userdoneid =
GETPOST(
"doneby",
"int");
820 $error++; $donotclearsession = 1;
822 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
824 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
826 if (empty($object->userownerid)) {
827 $error++; $donotclearsession = 1;
829 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
833 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
840 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
841 $eventDateStart = $object->datep;
842 $eventDateEnd = $object->datef;
844 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
845 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
846 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
847 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
848 $sql .=
" WHERE ac.id <> ".((int) $object->id);
849 $sql .=
" AND er.resource_id IN (";
850 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
851 $sql .=
" WHERE element_id = ".((int) $object->id);
852 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
853 $sql .=
" AND busy = 1";
855 $sql .=
" AND er.busy = 1";
859 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
861 if (!empty($eventDateEnd)) {
862 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
866 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
867 if (!empty($eventDateEnd)) {
868 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
873 $resql = $db->query($sql);
876 $object->error = $db->lasterror();
877 $object->errors[] = $object->error;
879 if ($db->num_rows(
$resql) > 0) {
882 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
883 while ($obj = $db->fetch_object(
$resql)) {
884 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
886 $object->errors[] = $object->error;
900 $result = $object->update($user);
904 $categories =
GETPOST(
'categories',
'array');
905 $object->setCategories($categories);
907 $object->loadReminders($remindertype, 0,
false);
908 if (!empty($object->reminders) && $object->datep >
dol_now()) {
909 foreach ($object->reminders as $reminder) {
910 $reminder->delete($user);
912 $object->reminders = array();
916 if ($addreminder ==
'on' && $object->datep >
dol_now()) {
921 $actionCommReminder->dateremind = $dateremind;
922 $actionCommReminder->typeremind = $remindertype;
923 $actionCommReminder->offsetunit = $offsetunit;
924 $actionCommReminder->offsetvalue = $offsetvalue;
925 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
926 $actionCommReminder->fk_actioncomm = $object->id;
927 if ($remindertype ==
'email') {
928 $actionCommReminder->fk_email_template = $modelmail;
932 foreach ($object->userassigned as $userassigned) {
933 $actionCommReminder->fk_user = $userassigned[
'id'];
934 $res = $actionCommReminder->create($user);
938 $langs->load(
"errors");
939 $error = $langs->trans(
'ErrorReminderActionCommCreation');
941 $action =
'create'; $donotclearsession = 1;
947 unset($_SESSION[
'assignedtouser']);
962 if (!empty($backtopage)) {
963 unset($_SESSION[
'assignedtouser']);
964 header(
"Location: ".$backtopage);
971 if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
973 $object->fetch_optionals();
974 $object->fetch_userassigned();
977 if ($user->rights->agenda->myactions->delete
978 || $user->rights->agenda->allactions->delete) {
979 $result = $object->delete();
982 header(
"Location: index.php");
994 if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1000 $newdate =
GETPOST(
'newdate',
'alpha');
1001 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1002 header(
"Location: ".$backtopage);
1006 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
1009 if ($datep != $object->datep) {
1010 if (!empty($object->datef)) {
1011 $object->datef += $datep - $object->datep;
1013 $object->datep = $datep;
1017 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
1018 $eventDateStart = $object->datep;
1019 $eventDateEnd = $object->datef;
1021 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1022 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1023 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1024 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
1025 $sql .=
" WHERE ac.id <> ".((int) $object->id);
1026 $sql .=
" AND er.resource_id IN (";
1027 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1028 $sql .=
" WHERE element_id = ".((int) $object->id);
1029 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
1030 $sql .=
" AND busy = 1";
1032 $sql .=
" AND er.busy = 1";
1036 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1038 if (!empty($eventDateEnd)) {
1039 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1043 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1044 if (!empty($eventDateEnd)) {
1045 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1050 $resql = $db->query($sql);
1053 $object->error = $db->lasterror();
1054 $object->errors[] = $object->error;
1056 if ($db->num_rows(
$resql) > 0) {
1059 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1060 while ($obj = $db->fetch_object(
$resql)) {
1061 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1063 $object->errors[] = $object->error;
1076 $result = $object->update($user);
1086 if (!empty($backtopage)) {
1087 header(
"Location: ".$backtopage);
1096 $permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read));
1097 if (empty($reshook)) {
1098 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1109 $arrayrecurrulefreq = array(
1110 'no'=>$langs->trans(
"OnceOnly"),
1111 'MONTHLY'=>$langs->trans(
"EveryMonth"),
1112 'WEEKLY'=>$langs->trans(
"EveryWeek")
1117 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
1120 if ($action ==
'create') {
1123 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1124 if (!empty($socpeopleassigned[0])) {
1125 $result = $contact->fetch($socpeopleassigned[0]);
1133 if (!empty($conf->use_javascript_ajax)) {
1134 print
"\n".
'<script type="text/javascript">';
1135 print
'$(document).ready(function () {
1136 function setdatefields()
1138 if ($("#fullday:checked").val() == null) {
1139 $(".fulldaystarthour").removeAttr("disabled");
1140 $(".fulldaystartmin").removeAttr("disabled");
1141 $(".fulldayendhour").removeAttr("disabled");
1142 $(".fulldayendmin").removeAttr("disabled");
1143 $("#p2").removeAttr("disabled");
1145 $(".fulldaystarthour").prop("disabled", true).val("00");
1146 $(".fulldaystartmin").prop("disabled", true).val("00");
1147 $(".fulldayendhour").prop("disabled", true).val("23");
1148 $(".fulldayendmin").prop("disabled", true).val("59");
1149 $("#p2").removeAttr("disabled");
1152 $("#fullday").change(function() {
1153 console.log("setdatefields");
1157 $("#selectcomplete").change(function() {
1158 console.log("we change the complete status - set the doneby");
1159 if ($("#selectcomplete").val() == 100) {
1160 if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).
'\');
1162 if ($(
"#selectcomplete").val() == 0) {
1163 $(
"#doneby").val(-1);
1167 $(
"#actioncode").change(
function() {
1168 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
1169 else $("#dateend").removeClass("fieldrequired");
1171 $("#aphour,#apmin").change(function() {
1172 if ($("#actioncode").val() == \'AC_RDV\') {
1173 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1174 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1175 $("#p2min").val($("#apmin").val());
1176 $("#p2day").val($("#apday").val());
1177 $("#p2month").val($("#apmonth").val());
1178 $("#p2year").val($("#apyear").val());
1179 $("#p2").val($("#ap").val());
1182 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1183 else $("#dateend").removeClass("fieldrequired");
1186 print
'</script>'.
"\n";
1189 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1190 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1191 print
'<input type="hidden" name="action" value="add">';
1192 print
'<input type="hidden" name="donotclearsession" value="1">';
1193 print
'<input type="hidden" name="page_y" value="">';
1195 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
dol_htmlentities($_SERVER[
"HTTP_REFERER"])).
'">';
1197 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1198 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1201 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1202 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1209 print
'<table class="border centpercent">';
1212 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1213 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1215 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1216 $selectedvalue =
GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : ($object->type_code ? $object->type_code : $default);
1217 print
$formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1222 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>';
1225 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>';
1228 $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1229 if ($userepeatevent) {
1232 print
' <div class="opacitymedium inline-block">';
1233 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1234 print
'<input type="hidden" name="recurid" value="'.(empty($object->recurid) ?
'' : $object->recurid).
'">';
1236 $selectedrecurrulefreq =
'no';
1237 $selectedrecurrulebymonthday =
'';
1238 $selectedrecurrulebyday =
'';
1239 $object->recurrule =
GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1240 $object->recurrule .=
GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1241 $object->recurrule .=
GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1245 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1246 $selectedrecurrulefreq = $reg[1];
1248 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) {
1249 $selectedrecurrulebymonthday = $reg[1];
1251 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1252 $selectedrecurrulebyday = $reg[1];
1255 print
$form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1261 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1262 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1265 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1266 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1269 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1270 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1271 print $langs->trans(
"Until").
" ";
1272 print
$form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1275 print
'<script type="text/javascript">
1276 jQuery(document).ready(function() {
1277 function init_repeat()
1279 console.log("recurrule: " + "'.$object->recurrule.
'");
1280 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1281 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1282 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1283 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1284 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1286 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1287 jQuery(".repeateventlimitdate").css("display", "inline-block");
1288 jQuery(".repeateventBYDAY").hide();
1290 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1292 jQuery(".repeateventBYMONTHDAY").hide();
1293 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1294 jQuery(".repeateventlimitdate").css("display", "inline-block");
1298 jQuery(".repeateventBYMONTHDAY").hide();
1299 jQuery(".repeateventBYDAY").hide();
1300 jQuery(".repeateventlimitdate").hide();
1304 jQuery("#recurrulefreq").change(function() {
1315 $datep = ($datep ? $datep : (is_null($object->datep) ?
'' : $object->datep));
1316 if (
GETPOST(
'datep',
'int', 1)) {
1319 $datef = ($datef ? $datef : $object->datef);
1320 if (
GETPOST(
'datef',
'int', 1)) {
1323 if (empty($datef) && !empty($datep)) {
1324 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
1325 $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');
1330 print
'<tr><td class="nowrap">';
1333 print
$form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1335 print
$form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1337 print
' <span class="hideonsmartphone"> - </span> ';
1339 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1341 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1345 print
'<tr><td class=""> </td><td></td></tr>';
1348 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1349 $listofuserid = array();
1350 $listofcontactid = array();
1351 $listofotherid = array();
1353 if (empty($donotclearsession)) {
1354 $assignedtouser =
GETPOST(
"assignedtouser") ?
GETPOST(
"assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1355 if ($assignedtouser) {
1356 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0);
1359 $listofuserid[$assignedtouser][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1360 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1362 if (!empty($_SESSION[
'assignedtouser'])) {
1363 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1365 $firstelem = reset($listofuserid);
1366 if (isset($listofuserid[$firstelem[
'id']])) {
1367 $listofuserid[$firstelem[
'id']][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1370 print
'<div class="assignedtouser">';
1371 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1376 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1377 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1378 print
$form->select_dolusers(
GETPOSTISSET(
"doneby") ?
GETPOST(
"doneby",
'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0),
'doneby', 1);
1383 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1384 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>';
1388 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1390 $percent = $complete !==
'' ? $complete : -1;
1394 $percent =
GETPOST(
'percentage',
'int');
1396 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1398 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1402 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1407 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1408 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1409 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1416 print
'<br><hr><br>';
1419 print
'<table class="border centpercent">';
1423 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1424 if (
GETPOST(
'socid',
'int') > 0) {
1426 $societe->fetch(
GETPOST(
'socid',
'int'));
1427 print $societe->getNomUrl(1);
1428 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOST(
'socid',
'int').
'">';
1431 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1433 if (!empty($user->socid)) {
1434 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300');
1436 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
1442 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1443 $preselectedids =
GETPOST(
'socpeopleassigned',
'array');
1444 if (
GETPOST(
'contactid',
'int')) {
1445 $preselectedids[
GETPOST(
'contactid',
'int')] =
GETPOST(
'contactid',
'int');
1447 if ($origin==
'contact') $preselectedids[
GETPOST(
'originid',
'int')] =
GETPOST(
'originid',
'int');
1448 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1449 print
$form->selectcontacts(
GETPOST(
'socid',
'int'), $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 quatrevingtpercent',
false, 0, array(),
false,
'multiple',
'contactid');
1455 $langs->load(
"projects");
1457 $projectid =
GETPOST(
'projectid',
'int');
1459 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1460 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1461 print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
1463 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1464 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1465 $urloption =
'?action=create&donotclearsession=1';
1469 print
"\n".
'<script type="text/javascript">';
1470 print
'$(document).ready(function () {
1471 $("#projectid").change(function () {
1472 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#projectid").val()+"&projectid="+$("#projectid").val();
1473 console.log("Call url to get new list of tasks: "+url);
1474 $.get(url, function(data) {
1476 if (data) $("#taskid").html(data).select2();
1480 print
'</script>'.
"\n";
1484 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1485 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1486 $projectsListId =
false;
1487 if (!empty($projectid)) {
1488 $projectsListId = $projectid;
1493 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500', $projectsListId);
1498 if (!empty($origin) && !empty($originid)) {
1499 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1501 $hasPermissionOnLinkedObject = 0;
1502 if ($user->hasRight($origin,
'read')) {
1503 $hasPermissionOnLinkedObject = 1;
1507 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1509 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1510 print
'<td colspan="3">';
1511 if ($hasPermissionOnLinkedObject) {
1513 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1514 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1515 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1516 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1518 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1525 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1526 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1527 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOST(
'priority',
'int') : ($object->priority ? $object->priority :
'')).
'" size="5">';
1532 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1533 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1534 $doleditor =
new DolEditor(
'note', (
GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') : $object->note_private),
'', 120,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1535 $doleditor->Create();
1540 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1541 print $hookmanager->resPrint;
1542 if (empty($reshook)) {
1543 print $object->showOptionals($extrafields,
'create',
$parameters);
1553 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1555 print
'<div class="reminderparameters" style="display: none;">';
1560 print
'<table class="border centpercent">';
1563 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1564 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOST(
'offsetvalue',
'int') :
'15').
'"> ';
1565 print
$form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1569 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1570 print
$form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1575 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1576 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1583 print
"\n".
'<script type="text/javascript">';
1584 print
'$(document).ready(function () {
1585 $("#addreminder").click(function(){
1586 console.log("Click on addreminder");
1588 $(".reminderparameters").show();
1590 $(".reminderparameters").hide();
1592 $("#selectremindertype").select2("destroy");
1593 $("#selectremindertype").select2();
1594 $("#select_offsetunittype_duration").select2("destroy");
1595 $("#select_offsetunittype_duration").select2();
1598 $("#selectremindertype").change(function(){
1599 console.log("Change on selectremindertype");
1600 var selected_option = $("#selectremindertype option:selected").val();
1601 if(selected_option == "email") {
1602 $("#select_actioncommsendmodel_mail").closest("tr").show();
1604 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1608 print
'</script>'.
"\n";
1613 print
$form->buttonsSaveCancel(
"Add");
1620 $result1 = $object->fetch($id);
1621 if ($result1 <= 0) {
1622 $langs->load(
"errors");
1623 print $langs->trans(
"ErrorRecordNotFound");
1629 $result2 = $object->fetch_thirdparty();
1630 $result2 = $object->fetch_projet();
1631 $result3 = $object->fetch_contact();
1632 $result4 = $object->fetch_userassigned();
1633 $result5 = $object->fetch_optionals();
1635 if ($listUserAssignedUpdated || $donotclearsession) {
1636 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
1638 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
1639 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
1642 $object->label =
GETPOST(
"label",
"alphanohtml");
1643 $object->datep = $datep;
1644 $object->datef = $datef;
1645 $object->percentage = $percentage;
1646 $object->priority =
GETPOST(
"priority",
"alphanohtml");
1647 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
1648 $object->location =
GETPOST(
'location',
"alpanohtml");
1649 $object->socid =
GETPOST(
"socid",
"int");
1650 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1651 foreach ($socpeopleassigned as $tmpid) {
1652 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1654 $object->contact_id =
GETPOST(
"contactid",
'int');
1655 $object->fk_project =
GETPOST(
"projectid",
'int');
1657 $object->note_private =
GETPOST(
"note",
'restricthtml');
1660 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1665 if ($object->authorid > 0) {
1666 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
1668 if ($object->usermodid > 0) {
1669 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
1680 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1684 if ($action ==
'delete') {
1685 print
$form->formconfirm(
"card.php?id=".urlencode($id), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1688 if ($action ==
'edit') {
1689 if (!empty($conf->use_javascript_ajax)) {
1690 print
"\n".
'<script type="text/javascript">';
1691 print
'$(document).ready(function () {
1692 function setdatefields()
1694 if ($("#fullday:checked").val() == null) {
1695 $(".fulldaystarthour").removeAttr("disabled");
1696 $(".fulldaystartmin").removeAttr("disabled");
1697 $(".fulldayendhour").removeAttr("disabled");
1698 $(".fulldayendmin").removeAttr("disabled");
1700 $(".fulldaystarthour").prop("disabled", true).val("00");
1701 $(".fulldaystartmin").prop("disabled", true).val("00");
1702 $(".fulldayendhour").prop("disabled", true).val("23");
1703 $(".fulldayendmin").prop("disabled", true).val("59");
1707 $("#fullday").change(function() {
1710 $("#actioncode").change(function() {
1711 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1712 else $("#dateend").removeClass("fieldrequired");
1715 print
'</script>'.
"\n";
1718 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1719 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1720 print
'<input type="hidden" name="action" value="update">';
1721 print
'<input type="hidden" name="id" value="'.$id.
'">';
1722 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1723 print
'<input type="hidden" name="page_y" value="">';
1725 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
dol_htmlentities($_SERVER[
"HTTP_REFERER"])).
'">';
1727 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code)) {
1728 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1733 print
'<table class="border tableforfield" width="100%">';
1736 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.$object->id.
'</td></tr>';
1739 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->elementtype !=
"ticket") {
1740 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1741 if ($object->type_code !=
'AC_OTH_AUTO') {
1742 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1743 print
$formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') : $object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1745 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1746 print $object->getTypePicto();
1747 print $langs->trans(
"Action".$object->type_code);
1753 if ($object->elementtype ==
'ticket') {
1754 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
1755 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1756 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/', $object->code) ?
' checked' :
'').
'></td></tr>';
1760 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>';
1763 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' :
'').
'>';
1764 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1827 print
'<tr><td class="nowrap">';
1832 print
'</td><td td colspan="3">';
1835 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 0,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1836 } elseif (
GETPOST(
"afaire") == 2) {
1837 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1839 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1841 print
' <span class="hideonsmartphone"> - </span> ';
1843 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1844 } elseif (
GETPOST(
"afaire") == 2) {
1845 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1847 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1851 print
'<tr><td class=""> </td><td></td></tr>';
1854 $listofuserid = array();
1855 if (empty($donotclearsession)) {
1856 if ($object->userownerid > 0) {
1857 $listofuserid[$object->userownerid] = array(
1858 'id'=>$object->userownerid,
1861 'transparency'=>$object->transparency,
1862 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
1863 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
1866 if (!empty($object->userassigned)) {
1868 $tmplist1 = $object->userassigned;
1869 foreach ($tmplist1 as $key => $val) {
1870 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
1871 $listofuserid[$val[
'id']] = $val;
1875 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1877 if (!empty($_SESSION[
'assignedtouser'])) {
1878 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1881 $listofcontactid = $object->socpeopleassigned;
1882 $listofotherid = $object->otherassigned;
1884 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
1885 print
'<div class="assignedtouser">';
1886 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1897 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1898 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td colspan="3">';
1899 print
$form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1,
'doneby', 1);
1904 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1905 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
1909 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
1910 $percent =
GETPOSTISSET(
"percentage") ?
GETPOST(
"percentage",
"int") : $object->percentage;
1911 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1916 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1917 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1919 $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
1920 $arrayselected = array();
1921 foreach ($cats as $cat) {
1922 $arrayselected[] = $cat->id;
1924 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1931 print
'<br><hr><br>';
1934 print
'<table class="border tableforfield centpercent">';
1938 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
1940 print
'<div class="maxwidth200onsmartphone">';
1942 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1945 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth200');
1950 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
1951 print
'<div class="maxwidth200onsmartphone">';
1952 print
img_picto(
'',
'contact',
'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'quatrevingtpercent',
false, 0, 0, array(),
'multiple',
'contactid');
1960 $langs->load(
"projects");
1962 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
1963 print
img_picto(
'',
'project',
'class="paddingrightonly"');
1964 $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth500');
1965 if ($numprojet == 0) {
1966 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>';
1972 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1973 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
1974 print
'<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
1979 if (!empty($object->fk_element) && !empty($object->elementtype)) {
1980 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1982 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
1984 if ($object->elementtype ==
'task' &&
isModEnabled(
'project')) {
1985 print
'<td id="project-task-input-container" >';
1987 $urloption =
'?action=create&donotclearsession=1';
1988 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
1991 print
"\n".
'<script type="text/javascript" >';
1992 print
'$(document).ready(function () {
1993 $("#projectid").change(function () {
1994 var url = "'.$url.
'&projectid="+$("#projectid").val();
1995 $.get(url, function(data) {
1996 console.log($( data ).find("#fk_element").html());
1997 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2001 print
'</script>'.
"\n";
2003 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
2004 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2010 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2011 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2019 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2021 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2022 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, $conf->fckeditor->enabled, ROWS_4,
'90%');
2023 $doleditor->Create();
2028 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
2029 print $hookmanager->resPrint;
2030 if (empty($reshook)) {
2031 print $object->showOptionals($extrafields,
'edit',
$parameters);
2038 $filteruserid = $user->id;
2039 if ($user->rights->agenda->allactions->read) {
2042 $object->loadReminders(
'', $filteruserid,
false);
2046 if (count($object->reminders) > 0) {
2047 $checked =
'checked';
2048 $keys = array_keys($object->reminders);
2049 $firstreminderId = array_shift($keys);
2051 $actionCommReminder = $object->reminders[$firstreminderId];
2055 $actionCommReminder->offsetvalue = 10;
2056 $actionCommReminder->offsetunit =
'i';
2057 $actionCommReminder->typeremind =
'email';
2060 print
'<label for="addreminder">'.$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder" '.$checked.
'><br>';
2062 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2066 print
'<table class="border centpercent">';
2069 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2070 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2071 print
$form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2075 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2076 print
$form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2080 if ($actionCommReminder->typeremind ==
'browser') {
2081 $hide =
'style="display:none;"';
2085 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2086 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2091 print
"\n".
'<script type="text/javascript">';
2092 print
'$(document).ready(function () {
2093 $("#addreminder").click(function(){
2095 $(".reminderparameters").show();
2097 $(".reminderparameters").hide();
2101 $("#selectremindertype").change(function(){
2102 var selected_option = $("#selectremindertype option:selected").val();
2103 if(selected_option == "email") {
2104 $("#select_actioncommsendmodel_mail").closest("tr").show();
2106 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2111 print
'</script>'.
"\n";
2118 print
$form->buttonsSaveCancel();
2127 if ($action ==
'clone') {
2128 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', array(),
'yes', 1);
2133 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2134 if (empty($reshook))
$formconfirm.=$hookmanager->resPrint;
2135 elseif ($reshook > 0)
$formconfirm=$hookmanager->resPrint;
2142 $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2143 $linkback .=
img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"');
2144 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("BackToList").'</span>';
2145 $linkback .= '</a>';
2146 $linkback .= '</li>';
2147 $linkback .= '<li class="noborder litext">';
2148 $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').'">';
2149 $linkback .=
img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"');
2150 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewCal").'</span>';
2151 $linkback .= '</a>';
2152 $linkback .= '</li>';
2153 $linkback .= '<li class="noborder litext">';
2154 $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').'">';
2155 $linkback .=
img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"');
2156 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewWeek").'</span>';
2157 $linkback .= '</a>';
2158 $linkback .= '</li>';
2159 $linkback .= '<li class="noborder litext">';
2160 $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').'">';
2161 $linkback .=
img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"');
2162 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewDay").'</span>';
2163 $linkback .= '</a>';
2164 $linkback .= '</li>';
2165 $linkback .= '<li class="noborder litext">';
2166 $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').'">';
2167 $linkback .=
img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"');
2168 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewPerUser").'</span>';
2169 $linkback .= '</a>';
2173 $reshook = $hookmanager->executeHooks('addCalendarView',
$parameters, $object, $action);
2174 if (empty($reshook)) {
2175 $linkback .= $hookmanager->resPrint;
2176 } elseif ($reshook > 1) {
2177 $linkback = $hookmanager->resPrint;
2182 $morehtmlref =
'<div class="refidno">';
2187 $langs->load(
"projects");
2189 if ($usercancreate) {
2190 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2191 if ($action !=
'classify') {
2192 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2194 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, ($action ==
'classify' ? 1 : 0), 0, 1,
'');
2196 if (!empty($object->fk_project)) {
2198 $proj->fetch($object->fk_project);
2199 $morehtmlref .= $proj->getNomUrl(1);
2201 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2206 $morehtmlref .=
'</div>';
2209 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2211 print
'<div class="fichecenter">';
2212 print
'<div class="fichehalfleft">';
2214 print
'<div class="underbanner clearboth"></div>';
2217 print
'<table class="border tableforfield" width="100%">';
2220 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
2221 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2222 print $object->getTypePicto();
2223 print $langs->trans(
"Action".$object->type_code);
2228 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2231 if ($object->recurid) {
2232 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag($object->recurid).
'</td></tr>';
2236 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2241 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2246 if (empty($object->fulldayevent)) {
2250 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2252 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2259 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2260 if (empty($object->fulldayevent)) {
2264 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2266 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2272 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2273 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
2277 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2278 $listofuserid = array();
2279 if (empty($donotclearsession)) {
2280 if ($object->userownerid > 0) {
2281 $listofuserid[$object->userownerid] = array(
2282 'id'=>$object->userownerid,
2283 'transparency'=>$object->transparency,
2284 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2285 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2288 if (!empty($object->userassigned)) {
2290 $tmplist1 = $object->userassigned;
2291 foreach ($tmplist1 as $key => $val) {
2292 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2293 $listofuserid[$val[
'id']] = $val;
2297 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2299 if (!empty($_SESSION[
'assignedtouser'])) {
2300 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2304 $listofcontactid = array();
2305 $listofotherid = array();
2306 print
'<div class="assignedtouser">';
2307 print
$form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2317 print
' </td></tr>';
2320 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
2321 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
2322 if ($object->userdoneid > 0) {
2323 $tmpuser =
new User($db);
2324 $tmpuser->fetch($object->userdoneid);
2325 print $tmpuser->getNomUrl(1);
2332 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2333 print
$form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2341 print
'<div class="fichehalfright">';
2343 print
'<div class="underbanner clearboth"></div>';
2344 print
'<table class="border tableforfield centpercent">';
2348 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2349 print
'<td>'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2350 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL') {
2351 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2352 print
"<br>".dol_print_phone($object->thirdparty->phone);
2358 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2361 if (!empty($object->socpeopleassigned)) {
2362 foreach ($object->socpeopleassigned as $cid => $Tab) {
2364 $result = $contact->fetch($cid);
2371 print $contact->getNomUrl(1);
2372 if ($object->type_code ==
'AC_TEL') {
2373 if (!empty($contact->phone_pro)) {
2374 print
'('.dol_print_phone($contact->phone_pro).
')';
2377 print
'<div class="paddingright"></div>';
2381 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2387 print
'<tr><td class="nowrap" class="titlefield">'.$langs->trans(
"Priority").
'</td><td>';
2388 print ($object->priority ? $object->priority :
'');
2393 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project'))) {
2394 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2395 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2399 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2407 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
2412 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2415 if (!empty($conf->global->AGENDA_REMINDER_EMAIL) || !empty($conf->global->AGENDA_REMINDER_BROWSER)) {
2416 $filteruserid = $user->id;
2417 if ($user->rights->agenda->allactions->read) {
2420 $object->loadReminders(
'', $filteruserid,
false);
2422 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2424 if (count($object->reminders) > 0) {
2425 $tmpuserstatic =
new User($db);
2427 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2428 print $TRemindTypes[$actioncommreminder->typeremind];
2429 if ($actioncommreminder->fk_user > 0) {
2430 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2431 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2433 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2434 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2435 print
' - <span class="opacitymedium">';
2436 print $langs->trans(
"NotSent");
2438 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2439 print
' - <span class="opacitymedium">';
2440 print $langs->trans(
"Done");
2454 print
'<div class="clearboth"></div>';
2463 print
'<div class="tabsAction">';
2466 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2467 if (empty($reshook)) {
2468 if ($action !=
'edit') {
2469 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2470 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2471 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2473 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2476 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2477 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2478 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>';
2480 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2483 if ($user->rights->agenda->allactions->delete ||
2484 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) {
2485 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2487 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2494 if ($action !=
'edit') {
2495 if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) {
2496 print
'<div style="clear:both;"></div><div class="fichecenter"><div class="fichehalfleft">';
2497 print
'<a name="builddoc"></a>';
2503 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2504 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2506 $genallowed = $user->rights->agenda->myactions->read;
2507 $delallowed = $user->rights->agenda->myactions->create;
2510 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2512 print
'</div><div class="fichehalfright">';
2515 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.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
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.