30 if (!defined(
"NOREDIRECTBYMAINTOLOGIN")) define(
'NOREDIRECTBYMAINTOLOGIN', 1);
32 require
'../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
37 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41 $langs->loadLangs(array(
"users",
"companies",
"agenda",
"commercial",
"other",
"orders",
"bills"));
43 $action =
GETPOST(
'action',
'aZ09');
44 $massaction =
GETPOST(
'massaction',
'alpha');
45 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'actioncommlist';
46 $resourceid =
GETPOST(
"search_resourceid",
"int") ?
GETPOST(
"search_resourceid",
"int") :
GETPOST(
"resourceid",
"int");
47 $pid =
GETPOST(
"search_projectid",
'int', 3) ?
GETPOST(
"search_projectid",
'int', 3) :
GETPOST(
"projectid",
'int', 3);
48 $search_status = (
GETPOST(
"search_status",
'alpha') !=
'') ?
GETPOST(
"search_status",
'alpha') :
GETPOST(
"status",
'alpha');
49 $type =
GETPOST(
'search_type',
'alphanohtml') ?
GETPOST(
'search_type',
'alphanohtml') :
GETPOST(
'type',
'alphanohtml');
50 $optioncss =
GETPOST(
'optioncss',
'alpha');
52 $month =
GETPOST(
"month",
'int');
54 $toselect =
GETPOST(
'toselect',
'array');
55 $confirm =
GETPOST(
'confirm',
'alpha');
58 if (
GETPOST(
'search_actioncode',
'array'))
60 $actioncode =
GETPOST(
'search_actioncode',
'array', 3);
61 if (!count($actioncode)) $actioncode =
'0';
63 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode") ==
'0' ?
'0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
65 if ($actioncode ==
'' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
66 $search_id =
GETPOST(
'search_id',
'alpha');
67 $search_title =
GETPOST(
'search_title',
'alpha');
68 $search_note =
GETPOST(
'search_note',
'alpha');
73 if ($search_status ==
'' && !
GETPOSTISSET(
'search_status')) $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
74 if (empty($action) && !
GETPOSTISSET(
'action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
76 $filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
77 $filtert =
GETPOST(
"search_filtert",
"int", 3) ?
GETPOST(
"search_filtert",
"int", 3) :
GETPOST(
"filtert",
"int", 3);
78 $usergroup =
GETPOST(
"search_usergroup",
"int", 3) ?
GETPOST(
"search_usergroup",
"int", 3) :
GETPOST(
"usergroup",
"int", 3);
79 $showbirthday = empty($conf->use_javascript_ajax) ? (
GETPOST(
"search_showbirthday",
"int") ?
GETPOST(
"search_showbirthday",
"int") :
GETPOST(
"showbirthday",
"int")) : 1;
83 $hookmanager->initHooks(array(
'agendalist'));
88 $extrafields->fetch_name_optionals_label($object->table_element);
90 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
92 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
97 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
98 $sortfield =
GETPOST(
"sortfield",
'alpha');
99 $sortorder =
GETPOST(
"sortorder",
'alpha');
101 if ($page == -1 || $page == null) { $page = 0; }
102 $offset = $limit * $page;
105 $sortorder =
"DESC,DESC";
106 if ($search_status ==
'todo') $sortorder =
"DESC,DESC";
110 $sortfield =
"a.datep,a.id";
111 if ($search_status ==
'todo') $sortfield =
"a.datep,a.id";
116 if ($user->socid) $socid = $user->socid;
118 if ($socid < 0) $socid =
'';
122 if (!$user->rights->agenda->allactions->read) $canedit = 0;
123 if (!$user->rights->agenda->allactions->read || $filter ==
'mine')
125 $filtert = $user->id;
128 $arrayfields = array(
129 'a.id'=>array(
'label'=>
"Ref",
'checked'=>1),
130 'owner'=>array(
'label'=>
"Owner",
'checked'=>1),
131 'c.libelle'=>array(
'label'=>
"Type",
'checked'=>1),
132 'a.label'=>array(
'label'=>
"Title",
'checked'=>1),
133 'a.note'=>array(
'label'=>
'Description',
'checked'=>0),
134 'a.datep'=>array(
'label'=>
"DateStart",
'checked'=>1),
135 'a.datep2'=>array(
'label'=>
"DateEnd",
'checked'=>1),
136 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
137 'a.fk_contact'=>array(
'label'=>
"Contact",
'checked'=>0),
138 'a.fk_element'=>array(
'label'=>
"LinkedObject",
'checked'=>1,
'enabled'=>(!empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))),
139 'a.datec'=>array(
'label'=>
'DateCreation',
'checked'=>0,
'position'=>510),
140 'a.tms'=>array(
'label'=>
'DateModification',
'checked'=>0,
'position'=>520),
141 'a.percent'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
144 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
155 if (
GETPOST(
'cancel',
'alpha'))
157 $action =
'list'; $massaction =
'';
163 if (is_array($_POST))
165 foreach ($_POST as $key => $val)
167 $param .=
'&'.$key.
'='.urlencode($val);
171 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php?'.$param);
175 $parameters = array(
'id'=>$socid);
176 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
177 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
180 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
182 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
192 $search_array_options = array();
195 if (empty($reshook) && !empty($massaction))
201 case 'set_all_events_to_todo':
205 case 'set_all_events_to_in_progress':
209 case 'set_all_events_to_finished':
216 foreach ($toselect as $toselectid)
218 $result = $object->updatePercent($toselectid, $percent);
231 $objectclass =
'ActionComm';
232 $objectlabel =
'Events';
235 $permissiontodelete = $user->rights->agenda->allactions->delete;
236 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
243 $form =
new Form($db);
244 $userstatic =
new User($db);
248 $nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
249 $nav .=
' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans(
"Refresh").
'">';
253 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
254 llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
257 $listofextcals = array();
260 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
261 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
262 if ($actioncode !=
'') {
263 if (is_array($actioncode)) {
264 foreach ($actioncode as $str_action) $param .=
"&search_actioncode[]=".urlencode($str_action);
265 }
else $param .=
"&search_actioncode=".urlencode($actioncode);
267 if ($resourceid > 0) $param .=
"&search_resourceid=".urlencode($resourceid);
268 if ($search_status !=
'' && $search_status > -1) $param .=
"&search_status=".urlencode($search_status);
269 if ($filter) $param .=
"&search_filter=".urlencode($filter);
270 if ($filtert) $param .=
"&search_filtert=".urlencode($filtert);
271 if ($socid) $param .=
"&search_socid=".urlencode($socid);
272 if ($showbirthday) $param .=
"&search_showbirthday=1";
273 if ($pid) $param .=
"&search_projectid=".urlencode($pid);
274 if ($type) $param .=
"&search_type=".urlencode($type);
275 if ($usergroup) $param .=
"&search_usergroup=".urlencode($usergroup);
276 if ($search_id !=
'') $param .=
'&search_title='.urlencode($search_id);
277 if ($search_title !=
'') $param .=
'&search_title='.urlencode($search_title);
278 if ($search_note !=
'') $param .=
'&search_note='.$search_note;
279 if (
GETPOST(
'datestartday',
'int')) $param .=
'&datestartday='.GETPOST(
'datestartday',
'int');
280 if (
GETPOST(
'datestartmonth',
'int')) $param .=
'&datestartmonth='.GETPOST(
'datestartmonth',
'int');
281 if (
GETPOST(
'datestartyear',
'int')) $param .=
'&datestartyear='.GETPOST(
'datestartyear',
'int');
282 if (
GETPOST(
'dateendday',
'int')) $param .=
'&dateendday='.GETPOST(
'dateendday',
'int');
283 if (
GETPOST(
'dateendmonth',
'int')) $param .=
'&dateendmonth='.GETPOST(
'dateendmonth',
'int');
284 if (
GETPOST(
'dateendyear',
'int')) $param .=
'&dateendyear='.GETPOST(
'dateendyear',
'int');
285 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
287 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
290 $arrayofmassactions = array(
291 'set_all_events_to_todo' => $langs->trans(
"SetAllEventsToTodo"),
292 'set_all_events_to_in_progress' => $langs->trans(
"SetAllEventsToInProgress"),
293 'set_all_events_to_finished' => $langs->trans(
"SetAllEventsToFinished"),
295 if ($user->rights->agenda->allactions->delete)
297 $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
299 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
300 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
303 if ($usergroup > 0) $sql .=
" DISTINCT";
304 $sql .=
" s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
305 $sql .=
" a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,";
306 $sql .=
' a.fk_user_author,a.fk_user_action,';
307 $sql .=
" a.fk_contact, a.note, a.percent as percent,";
308 $sql .=
" a.fk_element, a.elementtype, a.datec, a.tms as datem,";
309 $sql .=
" c.code as type_code, c.libelle as type_label,";
310 $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";
313 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
314 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
318 $parameters = array();
319 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
320 $sql .= $hookmanager->resPrint;
322 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
323 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"actioncomm_extrafields as ef ON (a.id = ef.fk_object) ";
324 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
325 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
326 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
327 $sql .=
" ,".MAIN_DB_PREFIX.
"c_actioncomm as c";
329 if ($resourceid > 0) $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
331 if ($filtert > 0 || $usergroup > 0) $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
332 if ($usergroup > 0) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
333 $sql .=
" WHERE c.id = a.fk_action";
334 $sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
336 if (!empty($actioncode))
338 if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
340 if ($actioncode ==
'AC_NON_AUTO') $sql .=
" AND c.type != 'systemauto'";
341 elseif ($actioncode ==
'AC_ALL_AUTO') $sql .= " AND c.
type = 'systemauto'";
343 if ($actioncode ==
'AC_OTH') $sql .=
" AND c.type != 'systemauto'";
344 if ($actioncode ==
'AC_OTH_AUTO') $sql .=
" AND c.type = 'systemauto'";
347 if ($actioncode ==
'AC_NON_AUTO') $sql .=
" AND c.type != 'systemauto'";
348 elseif ($actioncode ==
'AC_ALL_AUTO') $sql .= " AND c.
type = 'systemauto'";
350 if (is_array($actioncode))
352 $sql .=
" AND c.code IN ('".implode(
"','", $actioncode).
"')";
354 $sql .=
" AND c.code IN ('".implode(
"','", explode(
',', $actioncode)).
"')";
359 if ($resourceid > 0) $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
360 if ($pid) $sql .=
" AND a.fk_project=".$db->escape($pid);
361 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.
")";
362 if ($socid > 0) $sql .=
" AND s.rowid = ".$socid;
364 if ($filtert > 0 || $usergroup > 0) $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
365 if ($type) $sql .=
" AND c.id = ".(int) $type;
366 if ($search_status ==
'0') { $sql .=
" AND a.percent = 0"; }
367 if ($search_status ==
'-1') { $sql .=
" AND a.percent = -1"; }
368 if ($search_status ==
'50') { $sql .=
" AND (a.percent > 0 AND a.percent < 100)"; }
369 if ($search_status ==
'100') { $sql .=
" AND a.percent = 100"; }
370 if ($search_status ==
'done') { $sql .=
" AND (a.percent = 100)"; }
371 if ($search_status ==
'todo') { $sql .=
" AND (a.percent >= 0 AND a.percent < 100)"; }
373 if ($search_title) $sql .=
natural_search(
"a.label", $search_title);
376 if ($filtert > 0 || $usergroup > 0)
379 if ($filtert > 0) $sql .=
"(ar.fk_element = ".$filtert.
" OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert.
"))";
380 if ($usergroup > 0) $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".$usergroup;
385 if ($dateselect > 0) $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).
"'))";
386 if ($datestart > 0) $sql .=
" AND a.datep BETWEEN '".$db->idate($datestart).
"' AND '".$db->idate($datestart + 3600 * 24 - 1).
"'";
387 if ($dateend > 0) $sql .=
" AND a.datep2 BETWEEN '".$db->idate($dateend).
"' AND '".$db->idate($dateend + 3600 * 24 - 1).
"'";
390 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
393 $parameters = array();
394 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
395 $sql .= $hookmanager->resPrint;
397 $sql .= $db->order($sortfield, $sortorder);
399 $nbtotalofrecords =
'';
400 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
402 $result = $db->query($sql);
403 $nbtotalofrecords = $db->num_rows($result);
404 if (($page * $limit) > $nbtotalofrecords)
411 $sql .= $db->plimit($limit + 1, $offset);
414 dol_syslog(
"comm/action/list.php", LOG_DEBUG);
415 $resql = $db->query($sql);
419 $societestatic =
new Societe($db);
421 $num = $db->num_rows(
$resql);
423 $arrayofselected = is_array($toselect) ? $toselect : array();
426 $newtitle =
'<div class="nowrap clear inline-block minheight30 margintoponly">';
427 $newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
428 $newtitle .=
'</div>';
431 $tabactive =
'cardlist';
435 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
437 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
438 print '<input type="hidden" name="token" value="'.newToken().
'">';
439 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
440 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
441 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
442 print '<input type="hidden" name="type" value="'.$type.
'">';
445 if ($filter) $nav .=
'<input type="hidden" name="search_filter" value="'.$filter.
'">';
446 if ($showbirthday) $nav .=
'<input type="hidden" name="search_showbirthday" value="1">';
473 $parameters = array(); $object = null;
474 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
475 if (empty($reshook)) {
476 $s .= $hookmanager->resPrint;
477 } elseif ($reshook > 1) {
478 $s = $hookmanager->resPrint;
482 $viewmode .=
'<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
484 $viewmode .=
img_picto($langs->trans(
"List"),
'object_list-alt',
'class="pictoactionview block"');
486 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewList").
'</span></a>';
488 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_month&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
490 $viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview block"');
492 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span></a>';
494 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_week&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
496 $viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
498 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span></a>';
500 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_day&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
502 $viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
504 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span></a>';
506 $viewmode .=
'<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?action=show_peruser&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
508 $viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
510 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span></a>';
512 $viewmode .=
'<span class="marginrightonly"></span>';
515 $parameters = array(); $object = null;
516 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
517 if (empty($reshook)) {
518 $viewmode .= $hookmanager->resPrint;
519 } elseif ($reshook > 1) {
520 $viewmode = $hookmanager->resPrint;
525 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$tmpforcreatebutton[
'year'];
528 $hourminsec =
'100000';
530 $url = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
531 $url .=
'&datep='.sprintf(
"%04d%02d%02d", $tmpforcreatebutton[
'year'], $tmpforcreatebutton[
'mon'], $tmpforcreatebutton[
'mday']).$hourminsec;
532 $url .=
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
534 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddAction'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create);
536 $param .=
'&action='.$action;
538 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);
542 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
546 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
547 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
548 if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
551 print '<div class="liste_titre liste_titre_bydiv centpercent">';
552 print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
555 print '<div class="div-table-responsive">';
556 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
558 print '<tr class="liste_titre_filter">';
559 if (!empty($arrayfields[
'a.id'][
'checked'])) print
'<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.
'"></td>';
560 if (!empty($arrayfields[
'owner'][
'checked'])) print
'<td class="liste_titre"></td>';
561 if (!empty($arrayfields[
'c.libelle'][
'checked'])) print
'<td class="liste_titre"></td>';
562 if (!empty($arrayfields[
'a.label'][
'checked'])) print
'<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.
'"></td>';
563 if (!empty($arrayfields[
'a.note'][
'checked'])) print
'<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.
'"></td>';
564 if (!empty($arrayfields[
'a.datep'][
'checked'])) {
565 print
'<td class="liste_titre nowraponall" align="center">';
566 print $form->selectDate($datestart,
'datestart', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
569 if (!empty($arrayfields[
'a.datep2'][
'checked'])) {
570 print
'<td class="liste_titre nowraponall" align="center">';
571 print $form->selectDate($dateend,
'dateend', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
574 if (!empty($arrayfields[
's.nom'][
'checked'])) {
575 print
'<td class="liste_titre"></td>';
577 if (!empty($arrayfields[
'a.fk_contact'][
'checked'])) print
'<td class="liste_titre"></td>';
578 if (!empty($arrayfields[
'a.fk_element'][
'checked'])) print
'<td class="liste_titre"></td>';
581 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
584 $parameters = array(
'arrayfields'=>$arrayfields);
585 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
586 print $hookmanager->resPrint;
588 if (!empty($arrayfields[
'a.datec'][
'checked'])) print
'<td class="liste_titre"></td>';
589 if (!empty($arrayfields[
'a.tms'][
'checked'])) print
'<td class="liste_titre"></td>';
590 if (!empty($arrayfields[
'a.percent'][
'checked'])) {
591 print
'<td class="liste_titre center">';
592 $formactions->form_select_status_action(
'formaction', $search_status, 1,
'search_status', 1, 2,
'minwidth100imp maxwidth125');
597 print
'<td class="liste_titre" align="middle">';
598 $searchpicto = $form->showFilterButtons();
603 print
'<tr class="liste_titre">';
604 if (!empty($arrayfields[
'a.id'][
'checked']))
print_liste_field_titre($arrayfields[
'a.id'][
'label'], $_SERVER[
"PHP_SELF"],
"a.id", $param,
"",
"", $sortfield, $sortorder);
605 if (!empty($arrayfields[
'owner'][
'checked']))
print_liste_field_titre($arrayfields[
'owner'][
'label'], $_SERVER[
"PHP_SELF"],
"", $param,
"",
"", $sortfield, $sortorder);
606 if (!empty($arrayfields[
'c.libelle'][
'checked']))
print_liste_field_titre($arrayfields[
'c.libelle'][
'label'], $_SERVER[
"PHP_SELF"],
"c.libelle", $param,
"",
"", $sortfield, $sortorder);
607 if (!empty($arrayfields[
'a.label'][
'checked']))
print_liste_field_titre($arrayfields[
'a.label'][
'label'], $_SERVER[
"PHP_SELF"],
"a.label", $param,
"",
"", $sortfield, $sortorder);
608 if (!empty($arrayfields[
'a.note'][
'checked']))
print_liste_field_titre($arrayfields[
'a.note'][
'label'], $_SERVER[
"PHP_SELF"],
"a.note", $param,
"",
"", $sortfield, $sortorder);
610 if (!empty($arrayfields[
'a.datep'][
'checked']))
print_liste_field_titre($arrayfields[
'a.datep'][
'label'], $_SERVER[
"PHP_SELF"],
"a.datep,a.id", $param,
'',
'align="center"', $sortfield, $sortorder);
611 if (!empty($arrayfields[
'a.datep2'][
'checked']))
print_liste_field_titre($arrayfields[
'a.datep2'][
'label'], $_SERVER[
"PHP_SELF"],
"a.datep2", $param,
'',
'align="center"', $sortfield, $sortorder);
612 if (!empty($arrayfields[
's.nom'][
'checked']))
print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom", $param,
"",
"", $sortfield, $sortorder);
613 if (!empty($arrayfields[
'a.fk_contact'][
'checked']))
print_liste_field_titre($arrayfields[
'a.fk_contact'][
'label'], $_SERVER[
"PHP_SELF"],
"", $param,
"",
"", $sortfield, $sortorder);
614 if (!empty($arrayfields[
'a.fk_element'][
'checked']))
print_liste_field_titre($arrayfields[
'a.fk_element'][
'label'], $_SERVER[
"PHP_SELF"],
"", $param,
"",
"", $sortfield, $sortorder);
617 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
620 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
621 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
622 print $hookmanager->resPrint;
624 if (!empty($arrayfields[
'a.datec'][
'checked']))
print_liste_field_titre($arrayfields[
'a.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"a.datec,a.id", $param,
"",
'align="center"', $sortfield, $sortorder);
625 if (!empty($arrayfields[
'a.tms'][
'checked']))
print_liste_field_titre($arrayfields[
'a.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"a.tms,a.id", $param,
"",
'align="center"', $sortfield, $sortorder);
627 if (!empty($arrayfields[
'a.percent'][
'checked']))
print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"a.percent", $param,
"",
'align="center"', $sortfield, $sortorder);
628 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
631 $contactstatic =
new Contact($db);
633 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
635 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
637 $arraylist = $caction->liste_array(1,
'code',
'', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0),
'', 1);
638 $contactListCache = array();
640 while ($i < min($num, $limit))
642 $obj = $db->fetch_object(
$resql);
645 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code ==
'AC_OTH_AUTO')
651 $actionstatic->id = $obj->id;
652 $actionstatic->ref = $obj->id;
653 $actionstatic->code = $obj->code;
654 $actionstatic->type_code = $obj->type_code;
655 $actionstatic->type_label = $obj->type_label;
656 $actionstatic->type_picto = $obj->type_picto;
657 $actionstatic->label = $obj->label;
658 $actionstatic->location = $obj->location;
661 $actionstatic->fetchResources();
663 print
'<tr class="oddeven">';
666 if (!empty($arrayfields[
'a.id'][
'checked'])) {
668 print $actionstatic->getNomUrl(1, -1);
673 if (!empty($arrayfields[
'owner'][
'checked']))
675 print
'<td class="tdoverflowmax150">';
676 if ($obj->fk_user_action > 0)
678 $userstatic->fetch($obj->fk_user_action);
679 print $userstatic->getNomUrl(-1);
680 }
else print
' ';
685 if (!empty($arrayfields[
'c.libelle'][
'checked']))
687 print
'<td class="nowraponall">';
688 $actioncomm = $actionstatic;
691 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
693 if ($actioncomm->type_picto) {
694 $imgpicto =
img_picto(
'', $actioncomm->type_picto);
696 if ($actioncomm->type_code ==
'AC_RDV') $imgpicto =
img_picto(
'',
'object_group',
'',
false, 0, 0,
'',
'paddingright').
' ';
697 elseif ($actioncomm->type_code ==
'AC_TEL') $imgpicto =
img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
698 elseif ($actioncomm->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
699 elseif ($actioncomm->type_code == 'AC_EMAIL' || $actioncomm->type_code == 'AC_EMAIL_IN') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
700 elseif ($actioncomm->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
701 elseif ($actioncomm->type_code == 'AC_OTH' && $actioncomm->
code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' ';
702 elseif (!preg_match('/_AUTO/', $actioncomm->type_code)) $imgpicto = img_picto('', 'object_other', '', false, 0, 0, '', 'paddingright').' ';
707 $labeltype = $obj->type_code;
708 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH';
709 if ($actioncomm->type_code == 'AC_OTH' && $actioncomm->
code == 'TICKET_MSG') {
710 $labeltype = $langs->trans(
"Message");
712 if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype];
713 if ($obj->type_code ==
'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .=
' - '.$arraylist[$obj->code];
720 if (!empty($arrayfields[
'a.label'][
'checked'])) {
721 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actionstatic->label).
'">';
722 print $actionstatic->label;
727 if (!empty($arrayfields[
'a.note'][
'checked'])) {
728 print
'<td class="tdoverflowonsmartphone">';
730 print $form->textwithtooltip(
dol_trunc($text, 40), $actionstatic->note_private);
734 $formatToUse = $obj->fulldayevent ?
'day' :
'dayhour';
737 if (!empty($arrayfields[
'a.datep'][
'checked'])) {
738 print
'<td class="center nowraponall">';
739 print
dol_print_date($db->jdate($obj->dp), $formatToUse,
'tzuser');
741 if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
742 if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
743 if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1;
744 if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
745 if ($late) print
img_warning($langs->trans(
"Late")).
' ';
750 if (!empty($arrayfields[
'a.datep2'][
'checked'])) {
751 print
'<td class="center nowraponall">';
752 print
dol_print_date($db->jdate($obj->dp2), $formatToUse,
'tzuser');
757 if (!empty($arrayfields[
's.nom'][
'checked'])) {
758 print
'<td class="tdoverflowmax150">';
761 $societestatic->id = $obj->socid;
762 $societestatic->client = $obj->client;
763 $societestatic->name = $obj->societe;
764 $societestatic->email = $obj->socemail;
766 print $societestatic->getNomUrl(1,
'', 28);
767 }
else print
' ';
772 if (!empty($arrayfields[
'a.fk_contact'][
'checked'])) {
773 print
'<td class="tdoverflowmax100">';
775 if (!empty($actionstatic->socpeopleassigned))
777 $contactList = array();
778 foreach ($actionstatic->socpeopleassigned as $socpeopleassigned)
780 if (!isset($contactListCache[$socpeopleassigned[
'id']]))
784 if ($contact->fetch($socpeopleassigned[
'id']) > 0)
786 $contactListCache[$socpeopleassigned[
'id']] = $contact->getNomUrl(1,
'', 0);
787 $contactList[] = $contact->getNomUrl(1,
'', 0);
791 $contactList[] = $contactListCache[$socpeopleassigned[
'id']];
794 if (!empty($contactList)) {
795 print implode(
', ', $contactList);
797 } elseif ($obj->fk_contact > 0)
799 $contactstatic->id = $obj->fk_contact;
800 $contactstatic->email = $obj->email;
801 $contactstatic->lastname = $obj->lastname;
802 $contactstatic->firstname = $obj->firstname;
803 $contactstatic->phone_pro = $obj->phone_pro;
804 $contactstatic->phone_mobile = $obj->phone_mobile;
805 $contactstatic->phone_perso = $obj->phone_perso;
806 $contactstatic->country_id = $obj->country_id;
807 print $contactstatic->getNomUrl(1,
'', 0);
815 if (!empty($arrayfields[
'a.fk_element'][
'checked'])) {
816 print
'<td class="tdoverflowmax150">';
818 if ($obj->fk_element > 0 && !empty($obj->elementtype)) {
819 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
828 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
830 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
831 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
832 print $hookmanager->resPrint;
835 if (!empty($arrayfields[
'a.datec'][
'checked'])) {
837 print
'<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec),
'dayhour',
'tzuser').
'</td>';
840 if (!empty($arrayfields[
'a.tms'][
'checked'])) {
841 print
'<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem),
'dayhour',
'tzuser').
'</td>';
843 if (!empty($arrayfields[
'a.percent'][
'checked'])) {
845 $datep = $db->jdate($obj->datep);
846 print
'<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).
'</td>';
849 print
'<td class="nowrap center">';
850 if ($massactionbutton || $massaction)
853 if (in_array($obj->id, $arrayofselected)) $selected = 1;
854 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
Class to manage different types of events.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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.
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...
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
Class to manage agenda events (actions)
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
const EVENT_FINISHED
Typical value for a event that is in a finished state.
dol_now($mode= 'auto')
Return date for now.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
Class to manage Dolibarr users.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
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...
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
const EVENT_IN_PROGRESS
Typical value for a event that is in a progress state.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
const EVENT_TODO
Typical value for a event that is in a todo state.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode= '', $usergroupid= '', $excludetype= '', $resourceid=0)
Show filter form in agenda view.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
print $_SERVER["PHP_SELF"]
Edit parameters.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option= '')
Return link url to an object.