31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
36 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
40 $langs->loadLangs(array(
"users",
"companies",
"agenda",
"commercial",
"other",
"orders",
"bills"));
42 $action =
GETPOST(
'action',
'aZ09');
43 $massaction =
GETPOST(
'massaction',
'alpha');
44 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'actioncommlist';
45 $optioncss =
GETPOST(
'optioncss',
'alpha');
46 $toselect =
GETPOST(
'toselect',
'array');
47 $confirm =
GETPOST(
'confirm',
'alpha');
49 $disabledefaultvalues =
GETPOST(
'disabledefaultvalues',
'int');
51 $mode =
GETPOST(
'mode',
'aZ09');
52 if (empty($mode) && preg_match(
'/show_/', $action)) {
55 $resourceid =
GETPOST(
"search_resourceid",
"int") ?
GETPOST(
"search_resourceid",
"int") :
GETPOST(
"resourceid",
"int");
56 $pid =
GETPOST(
"search_projectid",
'int', 3) ?
GETPOST(
"search_projectid",
'int', 3) :
GETPOST(
"projectid",
'int', 3);
57 $search_status = (
GETPOST(
"search_status",
'aZ09') !=
'') ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
58 $type =
GETPOST(
'search_type',
'alphanohtml') ?
GETPOST(
'search_type',
'alphanohtml') :
GETPOST(
'type',
'alphanohtml');
60 $month =
GETPOST(
"month",
'int');
64 if (
GETPOST(
'search_actioncode',
'array')) {
65 $actioncode =
GETPOST(
'search_actioncode',
'array', 3);
66 if (!count($actioncode)) {
70 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode") ==
'0' ?
'0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
73 $search_id =
GETPOST(
'search_id',
'alpha');
74 $search_title =
GETPOST(
'search_title',
'alpha');
75 $search_note =
GETPOST(
'search_note',
'alpha');
78 $datestart_dtstart =
dol_mktime(0, 0, 0,
GETPOST(
'datestart_dtstartmonth',
'int'),
GETPOST(
'datestart_dtstartday',
'int'),
GETPOST(
'datestart_dtstartyear',
'int'),
'tzuserrel');
79 $datestart_dtend =
dol_mktime(23, 59, 59,
GETPOST(
'datestart_dtendmonth',
'int'),
GETPOST(
'datestart_dtendday',
'int'),
GETPOST(
'datestart_dtendyear',
'int'),
'tzuserrel');
80 $dateend_dtstart =
dol_mktime(0, 0, 0,
GETPOST(
'dateend_dtstartmonth',
'int'),
GETPOST(
'dateend_dtstartday',
'int'),
GETPOST(
'dateend_dtstartyear',
'int'),
'tzuserrel');
81 $dateend_dtend =
dol_mktime(23, 59, 59,
GETPOST(
'dateend_dtendmonth',
'int'),
GETPOST(
'dateend_dtendday',
'int'),
GETPOST(
'dateend_dtendyear',
'int'),
'tzuserrel');
82 if ($search_status ==
'' && !
GETPOSTISSET(
'search_status')) {
83 $search_status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
86 $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
89 $filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
90 $filtert =
GETPOST(
"search_filtert",
"int", 3) ?
GETPOST(
"search_filtert",
"int", 3) :
GETPOST(
"filtert",
"int", 3);
91 $usergroup =
GETPOST(
"search_usergroup",
"int", 3) ?
GETPOST(
"search_usergroup",
"int", 3) :
GETPOST(
"usergroup",
"int", 3);
92 $showbirthday = empty($conf->use_javascript_ajax) ? (
GETPOST(
"search_showbirthday",
"int") ?
GETPOST(
"search_showbirthday",
"int") :
GETPOST(
"showbirthday",
"int")) : 1;
96 $hookmanager->initHooks(array(
'agendalist'));
101 $extrafields->fetch_name_optionals_label($object->table_element);
103 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
105 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
106 $filtert = $user->id;
109 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
110 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
111 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
113 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
117 $offset = $limit * $page;
119 $sortorder =
"DESC,DESC";
120 if ($search_status ==
'todo') {
121 $sortorder =
"DESC,DESC";
125 $sortfield =
"a.datep,a.id";
126 if ($search_status ==
'todo') {
127 $sortfield =
"a.datep,a.id";
134 $socid = $user->socid;
141 if (empty($user->rights->agenda->myactions->read)) {
144 if (empty($user->rights->agenda->allactions->read)) {
147 if (empty($user->rights->agenda->allactions->read) || $filter ==
'mine') {
148 $filtert = $user->id;
151 $arrayfields = array(
152 'a.id'=>array(
'label'=>
"Ref",
'checked'=>1),
153 'owner'=>array(
'label'=>
"Owner",
'checked'=>1),
154 'c.libelle'=>array(
'label'=>
"Type",
'checked'=>1),
155 'a.label'=>array(
'label'=>
"Title",
'checked'=>1),
156 'a.note'=>array(
'label'=>
'Description',
'checked'=>0),
157 'a.datep'=>array(
'label'=>
"DateStart",
'checked'=>1),
158 'a.datep2'=>array(
'label'=>
"DateEnd",
'checked'=>1),
159 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
160 'a.fk_contact'=>array(
'label'=>
"Contact",
'checked'=>0),
161 'a.fk_element'=>array(
'label'=>
"LinkedObject",
'checked'=>1,
'enabled'=>(!empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))),
162 'a.datec'=>array(
'label'=>
'DateCreation',
'checked'=>0,
'position'=>510),
163 'a.tms'=>array(
'label'=>
'DateModification',
'checked'=>0,
'position'=>520),
164 'a.percent'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
167 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
173 if ($user->socid && $socid) {
182 if (
GETPOST(
'cancel',
'alpha')) {
189 if (is_array($_POST)) {
190 foreach ($_POST as $key => $val) {
191 $param .=
'&'.$key.
'='.urlencode($val);
195 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php?'.$param);
199 $parameters = array(
'id'=>$socid);
200 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
206 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
208 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
213 $datestart_dtstart =
'';
214 $datestart_dtend =
'';
215 $dateend_dtstart =
'';
226 $search_array_options = array();
229 if (empty($reshook) && !empty($massaction)) {
232 switch ($massaction) {
233 case 'set_all_events_to_todo':
237 case 'set_all_events_to_in_progress':
241 case 'set_all_events_to_finished':
246 if (isset($percent)) {
247 foreach ($toselect as $toselectid) {
248 $result = $object->updatePercent($toselectid, $percent);
258 if (empty($reshook)) {
259 $objectclass =
'ActionComm';
260 $objectlabel =
'Events';
263 $permissiontodelete = $user->rights->agenda->allactions->delete;
264 $permissiontoadd = $user->rights->agenda->myactions->create;
265 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
273 $userstatic =
new User($db);
277 $societestatic =
new Societe($db);
278 $contactstatic =
new Contact($db);
281 $nav .=
$form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
282 $nav .=
' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans(
"Refresh").
'">';
286 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
287 $title = $langs->trans(
"Agenda");
291 $listofextcals = array();
294 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
295 $param .=
'&contextpage='.urlencode($contextpage);
297 if ($limit > 0 && $limit != $conf->liste_limit) {
298 $param .=
'&limit='.urlencode($limit);
300 if ($actioncode !=
'') {
301 if (is_array($actioncode)) {
302 foreach ($actioncode as $str_action) {
303 $param .=
"&search_actioncode[]=".urlencode($str_action);
306 $param .=
"&search_actioncode=".urlencode($actioncode);
309 if ($resourceid > 0) {
310 $param .=
"&search_resourceid=".urlencode($resourceid);
312 if ($search_status !=
'') {
313 $param .=
"&search_status=".urlencode($search_status);
316 $param .=
"&search_filter=".urlencode($filter);
319 $param .=
"&search_filtert=".urlencode($filtert);
321 if ($usergroup > 0) {
322 $param .=
"&search_usergroup=".urlencode($usergroup);
325 $param .=
"&search_socid=".urlencode($socid);
328 $param .=
"&search_showbirthday=1";
331 $param .=
"&search_projectid=".urlencode($pid);
334 $param .=
"&search_type=".urlencode($type);
336 if ($search_id !=
'') {
337 $param .=
'&search_title='.urlencode($search_id);
339 if ($search_title !=
'') {
340 $param .=
'&search_title='.urlencode($search_title);
342 if ($search_note !=
'') {
343 $param .=
'&search_note='.urlencode($search_note);
345 if (
GETPOST(
'datestartday_dtstart',
'int')) {
346 $param .=
'&datestartday_dtstart='.GETPOST(
'datestartday_dtstart',
'int');
348 if (
GETPOST(
'datestartmonth_dtstart',
'int')) {
349 $param .=
'&datestartmonth_dtstart='.GETPOST(
'datestartmonth_dtstart',
'int');
351 if (
GETPOST(
'datestartyear_dtstart',
'int')) {
352 $param .=
'&datestartyear_dtstart='.GETPOST(
'datestartyear_dtstart',
'int');
354 if (
GETPOST(
'datestartday_dtend',
'int')) {
355 $param .=
'&datestartday_dtend='.GETPOST(
'datestartday_dtend',
'int');
357 if (
GETPOST(
'datestartmonth_dtend',
'int')) {
358 $param .=
'&datestartmonth_dtend='.GETPOST(
'datestartmonth_dtend',
'int');
360 if (
GETPOST(
'datestartyear_dtend',
'int')) {
361 $param .=
'&datestartyear_dtend='.GETPOST(
'datestartyear_dtend',
'int');
363 if (
GETPOST(
'dateendday_dtstart',
'int')) {
364 $param .=
'&dateendday_dtstart='.GETPOST(
'dateendday_dtstart',
'int');
366 if (
GETPOST(
'dateendmonth_dtstart',
'int')) {
367 $param .=
'&dateendmonth_dtstart='.GETPOST(
'dateendmonth_dtstart',
'int');
369 if (
GETPOST(
'dateendyear_dtstart',
'int')) {
370 $param .=
'&dateendyear_dtstart='.GETPOST(
'dateendyear_dtstart',
'int');
372 if (
GETPOST(
'dateendday_dtend',
'int')) {
373 $param .=
'&dateendday_dtend='.GETPOST(
'dateendday_dtend',
'int');
375 if (
GETPOST(
'dateendmonth_dtend',
'int')) {
376 $param .=
'&dateendmonth_dtend='.GETPOST(
'dateendmonth_dtend',
'int');
378 if (
GETPOST(
'dateendyear_dtend',
'int')) {
379 $param .=
'&dateendyear_dtend='.GETPOST(
'dateendyear_dtend',
'int');
381 if ($optioncss !=
'') {
382 $param .=
'&optioncss='.urlencode($optioncss);
385 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
387 $paramnoactionodate = $param;
390 $arrayofmassactions = array(
391 'set_all_events_to_todo' => $langs->trans(
"SetAllEventsToTodo"),
392 'set_all_events_to_in_progress' => $langs->trans(
"SetAllEventsToInProgress"),
393 'set_all_events_to_finished' => $langs->trans(
"SetAllEventsToFinished"),
395 if ($user->rights->agenda->allactions->delete) {
396 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
398 if (
isModEnabled(
'category') && $user->rights->agenda->myactions->create) {
399 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
401 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
402 $arrayofmassactions = array();
404 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
407 if ($usergroup > 0) {
410 $sql .=
" s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
411 $sql .=
" a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,";
412 $sql .=
" a.fk_user_author, a.fk_user_action,";
413 $sql .=
" a.fk_contact, a.note, a.percent as percent,";
414 $sql .=
" a.fk_element, a.elementtype, a.datec, a.tms as datem,";
415 $sql .=
" c.code as type_code, c.libelle as type_label, c.color as type_color, c.type as type_type, c.picto as type_picto,";
416 $sql .=
" sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id";
419 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
420 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
421 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
426 $parameters = array();
427 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
428 $sql .= $hookmanager->resPrint;
432 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
433 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"actioncomm_extrafields as ef ON (a.id = ef.fk_object)";
434 if (empty($user->rights->societe->client->voir) && !$socid) {
435 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
437 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
438 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
439 $sql .=
" ,".MAIN_DB_PREFIX.
"c_actioncomm as c";
441 if ($resourceid > 0) {
442 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
445 if ($filtert > 0 || $usergroup > 0) {
446 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
448 if ($usergroup > 0) {
449 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
451 $sql .=
" WHERE c.id = a.fk_action";
452 $sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
454 if (!empty($actioncode)) {
455 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
456 if ($actioncode ==
'AC_NON_AUTO') {
457 $sql .=
" AND c.type != 'systemauto'";
458 } elseif ($actioncode ==
'AC_ALL_AUTO') {
459 $sql .=
" AND c.type = 'systemauto'";
461 if ($actioncode ==
'AC_OTH') {
462 $sql .=
" AND c.type != 'systemauto'";
464 if ($actioncode ==
'AC_OTH_AUTO') {
465 $sql .=
" AND c.type = 'systemauto'";
469 if ($actioncode ==
'AC_NON_AUTO') {
470 $sql .=
" AND c.type != 'systemauto'";
471 } elseif ($actioncode ==
'AC_ALL_AUTO') {
472 $sql .=
" AND c.type = 'systemauto'";
474 if (is_array($actioncode)) {
475 $sql .=
" AND c.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
477 $sql .=
" AND c.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
482 if ($resourceid > 0) {
483 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
486 $sql .=
" AND a.fk_project=".((int) $pid);
488 if (empty($user->rights->societe->client->voir) && !$socid) {
489 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
492 $sql .=
" AND s.rowid = ".((int) $socid);
495 if ($filtert > 0 || $usergroup > 0) {
496 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
499 $sql .=
" AND c.id = ".((int) $type);
501 if ($search_status ==
'0') {
502 $sql .=
" AND a.percent = 0";
504 if ($search_status ==
'na') {
505 $sql .=
" AND a.percent = -1";
507 if ($search_status ==
'50') {
508 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
510 if ($search_status ==
'100') {
511 $sql .=
" AND a.percent = 100";
513 if ($search_status ==
'done') {
514 $sql .=
" AND (a.percent = 100)";
516 if ($search_status ==
'todo') {
517 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
529 if ($filtert > 0 || $usergroup > 0) {
532 $sql .=
"(ar.fk_element = ".((int) $filtert).
" OR (ar.fk_element IS NULL AND a.fk_user_action = ".((int) $filtert).
"))";
534 if ($usergroup > 0) {
535 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
541 if ($dateselect > 0) {
542 $sql .=
" AND ((a.datep2 >= '".$db->idate($dateselect).
"' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1).
"') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600).
"' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1).
"'))";
544 if ($datestart_dtstart > 0) {
545 $sql .=
" AND a.datep >= '".$db->idate($datestart_dtstart).
"'";
547 if ($datestart_dtend > 0) {
548 $sql .=
" AND a.datep <= '".$db->idate($datestart_dtend).
"'";
550 if ($dateend_dtstart > 0) {
551 $sql .=
" AND a.datep2 >= '".$db->idate($dateend_dtstart).
"'";
553 if ($dateend_dtend > 0) {
554 $sql .=
" AND a.datep2 <= '".$db->idate($dateend_dtend).
"'";
558 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
561 $parameters = array();
562 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
563 $sql .= $hookmanager->resPrint;
567 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
569 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
570 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
571 $resql = $db->query($sqlforcount);
573 $objforcount = $db->fetch_object(
$resql);
587 $sql .= $db->order($sortfield, $sortorder);
589 $sql .= $db->plimit($limit + 1, $offset);
592 $resql = $db->query($sql);
598 $num = $db->num_rows(
$resql);
600 $arrayofselected = is_array($toselect) ? $toselect : array();
603 $newtitle =
'<div class="nowrap clear inline-block minheight30 margintoponly">';
604 $newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
605 $newtitle .=
'</div>';
608 $tabactive =
'cardlist';
612 print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
614 if ($optioncss !=
'') {
615 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
617 print
'<input type="hidden" name="token" value="'.newToken().
'">';
618 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
619 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
620 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
621 print
'<input type="hidden" name="type" value="'.$type.
'">';
625 $nav .=
'<input type="hidden" name="search_filter" value="'.$filter.
'">';
628 $nav .=
'<input type="hidden" name="search_showbirthday" value="1">';
640 $parameters = array();
641 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
642 if (empty($reshook)) {
643 $s .= $hookmanager->resPrint;
644 } elseif ($reshook > 1) {
645 $s = $hookmanager->resPrint;
647 $viewyear = is_object($object) ?
dol_print_date($object->datep,
'%Y') :
'';
648 $viewmonth = is_object($object) ?
dol_print_date($object->datep,
'%m') :
'';
649 $viewday = is_object($object) ?
dol_print_date($object->datep,
'%d') :
'';
651 $viewmode .=
'<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
653 $viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
655 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewList").
'</span></a>';
657 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_month&year='.$viewyear.
'&month='.$viewmonth.
'&day='.$viewday.$paramnoactionodate.
'">';
659 $viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
661 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span></a>';
663 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_week&year='.$viewyear.
'&month='.$viewmonth.
'&day='.$viewday.$paramnoactionodate.
'">';
665 $viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
667 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span></a>';
669 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&year='.$viewyear.
'&month='.$viewmonth.
'&day='.$viewday.$paramnoactionodate.
'">';
671 $viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
673 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span></a>';
675 $viewmode .=
'<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=show_peruser&year='.$viewyear.
'&month='.$viewmonth.
'&day='.$viewday.$paramnoactionodate.
'">';
677 $viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
679 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span></a>';
681 $viewmode .=
'<span class="marginrightonly"></span>';
684 $parameters = array();
685 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
686 if (empty($reshook)) {
687 $viewmode .= $hookmanager->resPrint;
688 } elseif ($reshook > 1) {
689 $viewmode = $hookmanager->resPrint;
694 $newparam =
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$tmpforcreatebutton[
'year'];
699 $url = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
700 $url .=
'&datep='.sprintf(
"%04d%02d%02d", $tmpforcreatebutton[
'year'], $tmpforcreatebutton[
'mon'], $tmpforcreatebutton[
'mday']).$hourminsec;
701 $url .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
703 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddAction'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create);
705 $param .=
'&mode='.$mode;
707 print_barre_liste($langs->trans(
"Agenda"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 *
$nbtotalofrecords,
'object_action', 0, $nav.$newcardbutton,
'', $limit, 0, 0, 1, $viewmode);
712 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
716 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
717 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
718 if ($massactionbutton) {
719 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
723 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
724 print_actions_filter(
$form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
727 print
'<div class="div-table-responsive">';
728 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
730 print
'<tr class="liste_titre_filter">';
733 print
'<td class="liste_titre" align="middle">';
734 $searchpicto =
$form->showFilterButtons(
'left');
738 if (!empty($arrayfields[
'a.id'][
'checked'])) {
739 print
'<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.
'"></td>';
741 if (!empty($arrayfields[
'owner'][
'checked'])) {
742 print
'<td class="liste_titre"></td>';
744 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
745 print
'<td class="liste_titre"></td>';
747 if (!empty($arrayfields[
'a.label'][
'checked'])) {
748 print
'<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.
'"></td>';
750 if (!empty($arrayfields[
'a.note'][
'checked'])) {
751 print
'<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.
'"></td>';
753 if (!empty($arrayfields[
'a.datep'][
'checked'])) {
754 print
'<td class="liste_titre nowraponall" align="center">';
755 print
'<div class="nowrap">';
756 print
$form->selectDate($datestart_dtstart,
'datestart_dtstart', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'),
'tzuserrel');
758 print
'<div class="nowrap">';
759 print
$form->selectDate($datestart_dtend,
'datestart_dtend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'To'),
'tzuserrel');
763 if (!empty($arrayfields[
'a.datep2'][
'checked'])) {
764 print
'<td class="liste_titre nowraponall" align="center">';
765 print
'<div class="nowrap">';
766 print
$form->selectDate($dateend_dtstart,
'dateend_dtstart', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'),
'tzuserrel');
768 print
'<div class="nowrap">';
769 print
$form->selectDate($dateend_dtend,
'dateend_dtend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'To'),
'tzuserrel');
773 if (!empty($arrayfields[
's.nom'][
'checked'])) {
774 print
'<td class="liste_titre"></td>';
776 if (!empty($arrayfields[
'a.fk_contact'][
'checked'])) {
777 print
'<td class="liste_titre"></td>';
779 if (!empty($arrayfields[
'a.fk_element'][
'checked'])) {
780 print
'<td class="liste_titre"></td>';
784 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
787 $parameters = array(
'arrayfields'=>$arrayfields);
788 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
789 print $hookmanager->resPrint;
791 if (!empty($arrayfields[
'a.datec'][
'checked'])) {
792 print
'<td class="liste_titre"></td>';
794 if (!empty($arrayfields[
'a.tms'][
'checked'])) {
795 print
'<td class="liste_titre"></td>';
797 if (!empty($arrayfields[
'a.percent'][
'checked'])) {
798 print
'<td class="liste_titre right parentonrightofpage">';
799 $formactions->form_select_status_action(
'formaction', $search_status, 1,
'search_status', 1, 2,
'search_status width100 onrightofpage');
804 print
'<td class="liste_titre" align="middle">';
805 $searchpicto =
$form->showFilterButtons();
811 $totalarray = array();
812 $totalarray[
'nbfield'] = 0;
816 print
'<tr class="liste_titre">';
818 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
820 if (!empty($arrayfields[
'a.id'][
'checked'])) {
821 print_liste_field_titre($arrayfields[
'a.id'][
'label'], $_SERVER[
"PHP_SELF"],
"a.id", $param,
"",
"", $sortfield, $sortorder);
822 $totalarray[
'nbfield']++;
824 if (!empty($arrayfields[
'owner'][
'checked'])) {
825 print_liste_field_titre($arrayfields[
'owner'][
'label'], $_SERVER[
"PHP_SELF"],
"", $param,
"",
"", $sortfield, $sortorder);
826 $totalarray[
'nbfield']++;
828 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
829 print_liste_field_titre($arrayfields[
'c.libelle'][
'label'], $_SERVER[
"PHP_SELF"],
"c.libelle", $param,
"",
"", $sortfield, $sortorder);
830 $totalarray[
'nbfield']++;
832 if (!empty($arrayfields[
'a.label'][
'checked'])) {
833 print_liste_field_titre($arrayfields[
'a.label'][
'label'], $_SERVER[
"PHP_SELF"],
"a.label", $param,
"",
"", $sortfield, $sortorder);
834 $totalarray[
'nbfield']++;
836 if (!empty($arrayfields[
'a.note'][
'checked'])) {
837 print_liste_field_titre($arrayfields[
'a.note'][
'label'], $_SERVER[
"PHP_SELF"],
"a.note", $param,
"",
"", $sortfield, $sortorder);
838 $totalarray[
'nbfield']++;
841 if (!empty($arrayfields[
'a.datep'][
'checked'])) {
842 print_liste_field_titre($arrayfields[
'a.datep'][
'label'], $_SERVER[
"PHP_SELF"],
"a.datep,a.id", $param,
'',
'align="center"', $sortfield, $sortorder);
843 $totalarray[
'nbfield']++;
845 if (!empty($arrayfields[
'a.datep2'][
'checked'])) {
846 print_liste_field_titre($arrayfields[
'a.datep2'][
'label'], $_SERVER[
"PHP_SELF"],
"a.datep2", $param,
'',
'align="center"', $sortfield, $sortorder);
847 $totalarray[
'nbfield']++;
849 if (!empty($arrayfields[
's.nom'][
'checked'])) {
850 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom", $param,
"",
"", $sortfield, $sortorder);
851 $totalarray[
'nbfield']++;
853 if (!empty($arrayfields[
'a.fk_contact'][
'checked'])) {
854 print_liste_field_titre($arrayfields[
'a.fk_contact'][
'label'], $_SERVER[
"PHP_SELF"],
"", $param,
"",
"", $sortfield, $sortorder);
855 $totalarray[
'nbfield']++;
857 if (!empty($arrayfields[
'a.fk_element'][
'checked'])) {
858 print_liste_field_titre($arrayfields[
'a.fk_element'][
'label'], $_SERVER[
"PHP_SELF"],
"", $param,
"",
"", $sortfield, $sortorder);
859 $totalarray[
'nbfield']++;
862 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
864 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
865 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
866 print $hookmanager->resPrint;
868 if (!empty($arrayfields[
'a.datec'][
'checked'])) {
869 print_liste_field_titre($arrayfields[
'a.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"a.datec,a.id", $param,
"",
'align="center"', $sortfield, $sortorder);
870 $totalarray[
'nbfield']++;
872 if (!empty($arrayfields[
'a.tms'][
'checked'])) {
873 print_liste_field_titre($arrayfields[
'a.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"a.tms,a.id", $param,
"",
'align="center"', $sortfield, $sortorder);
874 $totalarray[
'nbfield']++;
877 if (!empty($arrayfields[
'a.percent'][
'checked'])) {
878 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"a.percent", $param,
"",
'align="center"', $sortfield, $sortorder);
879 $totalarray[
'nbfield']++;
882 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
884 $totalarray[
'nbfield']++;
888 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
890 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
892 $arraylist = $caction->liste_array(1,
'code',
'', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0),
'', 1);
893 $contactListCache = array();
900 $imaxinloop = ($limit ? min($num, $limit) : $num);
901 while ($i < $imaxinloop) {
902 $obj = $db->fetch_object(
$resql);
908 $object->setVarsFromFetchObj($obj);
911 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code ==
'AC_OTH_AUTO') {
916 $actionstatic->id = $obj->id;
917 $actionstatic->ref = $obj->id;
918 $actionstatic->code = $obj->code;
919 $actionstatic->type_code = $obj->type_code;
920 $actionstatic->type_label = $obj->type_label;
921 $actionstatic->type_picto = $obj->type_picto;
922 $actionstatic->type_color = $obj->type_color;
923 $actionstatic->label = $obj->label;
924 $actionstatic->location = $obj->location;
926 $actionstatic->datep = $db->jdate($obj->dp);
927 $actionstatic->percentage = $obj->percent;
928 $actionstatic->authorid = $obj->fk_user_author;
929 $actionstatic->userownerid = $obj->fk_user_action;
933 if (!empty($arrayfields[
'a.fk_contact'][
'checked'])) {
934 $actionstatic->fetchResources();
937 print
'<tr class="oddeven">';
940 print
'<td class="nowrap center">';
941 if ($massactionbutton || $massaction) {
943 if (in_array($obj->id, $arrayofselected)) {
946 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
951 if (!empty($arrayfields[
'a.id'][
'checked'])) {
952 print
'<td class="nowraponall">';
953 print $actionstatic->getNomUrl(1, -1);
958 if (!empty($arrayfields[
'owner'][
'checked'])) {
959 print
'<td class="tdoverflowmax150">';
960 if ($obj->fk_user_action > 0) {
961 $userstatic->fetch($obj->fk_user_action);
962 print $userstatic->getNomUrl(-1);
970 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
971 print
'<td class="nowraponall">';
972 print $actionstatic->getTypePicto();
973 $labeltype = $obj->type_code;
974 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
975 $labeltype =
'AC_OTH';
977 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
978 $labeltype = $langs->trans(
"Message");
980 if (!empty($arraylist[$labeltype])) {
981 $labeltype = $arraylist[$labeltype];
983 if ($obj->type_code ==
'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) {
984 $labeltype .=
' - '.$arraylist[$obj->code];
992 if (!empty($arrayfields[
'a.label'][
'checked'])) {
993 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actionstatic->label).
'">';
994 print $actionstatic->label;
999 if (!empty($arrayfields[
'a.note'][
'checked'])) {
1000 print
'<td class="tdoverflowonsmartphone">';
1002 print
$form->textwithtooltip(
dol_trunc($text, 48), $actionstatic->note_private);
1006 $formatToUse = $obj->fulldayevent ?
'day' :
'dayhour';
1009 if (!empty($arrayfields[
'a.datep'][
'checked'])) {
1010 print
'<td class="center nowraponall">';
1011 if (empty($obj->fulldayevent)) {
1012 print
dol_print_date($db->jdate($obj->dp), $formatToUse,
'tzuserrel');
1015 print
dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday :
'tzuserrel'));
1018 if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) {
1028 if (!empty($arrayfields[
'a.datep2'][
'checked'])) {
1029 print
'<td class="center nowraponall">';
1030 if (empty($obj->fulldayevent)) {
1031 print
dol_print_date($db->jdate($obj->dp2), $formatToUse,
'tzuserrel');
1034 print
dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday :
'tzuserrel'));
1040 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1041 print
'<td class="tdoverflowmax150">';
1042 if ($obj->socid > 0) {
1043 $societestatic->id = $obj->socid;
1044 $societestatic->client = $obj->client;
1045 $societestatic->name = $obj->societe;
1046 $societestatic->email = $obj->socemail;
1048 print $societestatic->getNomUrl(1,
'', 28);
1056 if (!empty($arrayfields[
'a.fk_contact'][
'checked'])) {
1057 print
'<td class="tdoverflowmax100">';
1059 if (!empty($actionstatic->socpeopleassigned)) {
1060 $contactList = array();
1061 foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) {
1062 if (!isset($contactListCache[$socpeopleassigned[
'id']])) {
1065 if ($contact->fetch($socpeopleassigned[
'id']) > 0) {
1066 $contactListCache[$socpeopleassigned[
'id']] = $contact->getNomUrl(1,
'', 0);
1067 $contactList[] = $contact->getNomUrl(1,
'', 0);
1071 $contactList[] = $contactListCache[$socpeopleassigned[
'id']];
1074 if (!empty($contactList)) {
1075 print implode(
', ', $contactList);
1077 } elseif ($obj->fk_contact > 0) {
1078 $contactstatic->id = $obj->fk_contact;
1079 $contactstatic->email = $obj->email;
1080 $contactstatic->lastname = $obj->lastname;
1081 $contactstatic->firstname = $obj->firstname;
1082 $contactstatic->phone_pro = $obj->phone_pro;
1083 $contactstatic->phone_mobile = $obj->phone_mobile;
1084 $contactstatic->phone_perso = $obj->phone_perso;
1085 $contactstatic->country_id = $obj->country_id;
1086 print $contactstatic->getNomUrl(1,
'', 0);
1094 if (!empty($arrayfields[
'a.fk_element'][
'checked'])) {
1095 print
'<td class="tdoverflowmax150">';
1097 if ($obj->fk_element > 0 && !empty($obj->elementtype)) {
1098 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1107 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1109 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1110 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1111 print $hookmanager->resPrint;
1114 if (!empty($arrayfields[
'a.datec'][
'checked'])) {
1116 print
'<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec),
'dayhour',
'tzuserrel').
'</td>';
1119 if (!empty($arrayfields[
'a.tms'][
'checked'])) {
1120 print
'<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem),
'dayhour',
'tzuserrel').
'</td>';
1122 if (!empty($arrayfields[
'a.percent'][
'checked'])) {
1124 $datep = $db->jdate($obj->dp);
1125 print
'<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).
'</td>';
1129 print
'<td class="nowrap center">';
1130 if ($massactionbutton || $massaction) {
1132 if (in_array($obj->id, $arrayofselected)) {
1135 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1146 print
'<tr><td colspan="'.$totalarray[
'nbfield'].
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1150 print
'</table>'.
"\n";
1151 print
'</div>'.
"\n";
1153 print
'</form>'.
"\n";