1<?php 2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2003 Eric Seigne <erics@rycks.com> 4 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> 5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> 6 * Copyright (C) 2017 Open-DSI <support@open-dsi.fr> 7 * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> 8 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 3 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program. If not, see <https://www.gnu.org/licenses/>. 22 */ 23 24/** 25 * \file htdocs/comm/action/list.php 26 * \ingroup agenda 27 * \brief Page to list actions 28 */ 29 30if (!defined("NOREDIRECTBYMAINTOLOGIN")) { 31 define('NOREDIRECTBYMAINTOLOGIN', 1); 32} 33 34require '../../main.inc.php'; 35require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; 36require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; 37require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; 38require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; 39include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; 40require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; 41 42// Load translation files required by the page 43$langs->loadLangs(array("users", "companies", "agenda", "commercial", "other", "orders", "bills")); 44 45$action = GETPOST('action', 'aZ09'); 46$massaction = GETPOST('massaction', 'alpha'); 47$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search 48$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); 49$pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3); 50$search_status = (GETPOST("search_status", 'aZ09') != '') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); 51$type = GETPOST('search_type', 'alphanohtml') ?GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml'); 52$optioncss = GETPOST('optioncss', 'alpha'); 53$year = GETPOST("year", 'int'); 54$month = GETPOST("month", 'int'); 55$day = GETPOST("day", 'int'); 56$toselect = GETPOST('toselect', 'array'); 57$confirm = GETPOST('confirm', 'alpha'); 58 59// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) 60if (GETPOST('search_actioncode', 'array')) { 61 $actioncode = GETPOST('search_actioncode', 'array', 3); 62 if (!count($actioncode)) { 63 $actioncode = '0'; 64 } 65} else { 66 $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)); 67} 68if ($actioncode == '' && empty($actioncodearray)) { 69 $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); 70} 71$search_id = GETPOST('search_id', 'alpha'); 72$search_title = GETPOST('search_title', 'alpha'); 73$search_note = GETPOST('search_note', 'alpha'); 74 75$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'), 'tzuserrel'); 76$datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'), 'tzuserrel'); 77$dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'), 'tzuserrel'); 78if ($search_status == '' && !GETPOSTISSET('search_status')) { 79 $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); 80} 81if (empty($action) && !GETPOSTISSET('action')) { 82 $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); 83} 84 85$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); 86$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); 87$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); 88$showbirthday = empty($conf->use_javascript_ajax) ? (GETPOST("search_showbirthday", "int") ?GETPOST("search_showbirthday", "int") : GETPOST("showbirthday", "int")) : 1; 89 90// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context 91$object = new ActionComm($db); 92$hookmanager->initHooks(array('agendalist')); 93 94$extrafields = new ExtraFields($db); 95 96// fetch optionals attributes and labels 97$extrafields->fetch_name_optionals_label($object->table_element); 98 99$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); 100// If not choice done on calendar owner, we filter on user. 101if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { 102 $filtert = $user->id; 103} 104 105$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; 106$sortfield = GETPOST("sortfield", 'alpha'); 107$sortorder = GETPOST("sortorder", 'alpha'); 108$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); 109if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { 110 // If $page is not defined, or '' or -1 or if we click on clear filters 111 $page = 0; 112} 113$offset = $limit * $page; 114if (!$sortorder) { 115 $sortorder = "DESC,DESC"; 116 if ($search_status == 'todo') { 117 $sortorder = "DESC,DESC"; 118 } 119} 120if (!$sortfield) { 121 $sortfield = "a.datep,a.id"; 122 if ($search_status == 'todo') { 123 $sortfield = "a.datep,a.id"; 124 } 125} 126 127// Security check 128$socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); 129if ($user->socid) { 130 $socid = $user->socid; 131} 132if ($socid < 0) { 133 $socid = ''; 134} 135 136$canedit = 1; 137if (!$user->rights->agenda->myactions->read) { 138 accessforbidden(); 139} 140if (!$user->rights->agenda->allactions->read) { 141 $canedit = 0; 142} 143if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me 144 $filtert = $user->id; 145} 146 147$arrayfields = array( 148 'a.id'=>array('label'=>"Ref", 'checked'=>1), 149 'owner'=>array('label'=>"Owner", 'checked'=>1), 150 'c.libelle'=>array('label'=>"Type", 'checked'=>1), 151 'a.label'=>array('label'=>"Title", 'checked'=>1), 152 'a.note'=>array('label'=>'Description', 'checked'=>0), 153 'a.datep'=>array('label'=>"DateStart", 'checked'=>1), 154 'a.datep2'=>array('label'=>"DateEnd", 'checked'=>1), 155 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 156 'a.fk_contact'=>array('label'=>"Contact", 'checked'=>0), 157 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>1, 'enabled'=>(!empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))), 158 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>510), 159 'a.tms'=>array('label'=>'DateModification', 'checked'=>0, 'position'=>520), 160 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) 161); 162// Extra fields 163include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; 164 165$object->fields = dol_sort_array($object->fields, 'position'); 166$arrayfields = dol_sort_array($arrayfields, 'position'); 167 168$result = restrictedArea($user, 'agenda', 0, '', 'myactions'); 169if ($user->socid && $socid) { 170 $result = restrictedArea($user, 'societe', $socid); 171} 172 173 174/* 175 * Actions 176 */ 177 178if (GETPOST('cancel', 'alpha')) { 179 $action = 'list'; $massaction = ''; 180} 181 182if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { 183 $param = ''; 184 if (is_array($_POST)) { 185 foreach ($_POST as $key => $val) { 186 $param .= '&'.$key.'='.urlencode($val); 187 } 188 } 189 //print $param; 190 header("Location: ".DOL_URL_ROOT.'/comm/action/index.php?'.$param); 191 exit; 192} 193 194$parameters = array('id'=>$socid); 195$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 196if ($reshook < 0) { 197 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 198} 199 200// Selection of new fields 201include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; 202// Purge search criteria 203if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers 204 //$actioncode=''; 205 $search_id = ''; 206 $search_title = ''; 207 $search_note = ''; 208 $datestart = ''; 209 $dateend = ''; 210 $search_status = ''; 211 $toselect = ''; 212 $search_array_options = array(); 213} 214 215if (empty($reshook) && !empty($massaction)) { 216 unset($percent); 217 218 switch ($massaction) { 219 case 'set_all_events_to_todo': 220 $percent = ActionComm::EVENT_TODO; 221 break; 222 223 case 'set_all_events_to_in_progress': 224 $percent = ActionComm::EVENT_IN_PROGRESS; 225 break; 226 227 case 'set_all_events_to_finished': 228 $percent = ActionComm::EVENT_FINISHED; 229 break; 230 } 231 232 if (isset($percent)) { 233 foreach ($toselect as $toselectid) { 234 $result = $object->updatePercent($toselectid, $percent); 235 if ($result < 0) { 236 dol_print_error($db); 237 break; 238 } 239 } 240 } 241} 242 243// As mass deletion happens with a confirm step, $massaction is not use for the final step (deletion). 244if (empty($reshook)) { 245 $objectclass = 'ActionComm'; 246 $objectlabel = 'Events'; 247 $uploaddir = true; 248 // Only users that can delete any event can remove records. 249 $permissiontodelete = $user->rights->agenda->allactions->delete; 250 $permissiontoadd = $user->rights->agenda->myactions->create; 251 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; 252} 253 254/* 255 * View 256 */ 257 258$form = new Form($db); 259$userstatic = new User($db); 260$formactions = new FormActions($db); 261 262$nav = ''; 263$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); 264$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">'; 265 266$now = dol_now(); 267 268$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; 269llxHeader('', $langs->trans("Agenda"), $help_url); 270 271// Define list of all external calendars 272$listofextcals = array(); 273 274$param = ''; 275if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { 276 $param .= '&contextpage='.urlencode($contextpage); 277} 278if ($limit > 0 && $limit != $conf->liste_limit) { 279 $param .= '&limit='.urlencode($limit); 280} 281if ($actioncode != '') { 282 if (is_array($actioncode)) { 283 foreach ($actioncode as $str_action) { 284 $param .= "&search_actioncode[]=".urlencode($str_action); 285 } 286 } else { 287 $param .= "&search_actioncode=".urlencode($actioncode); 288 } 289} 290if ($resourceid > 0) { 291 $param .= "&search_resourceid=".urlencode($resourceid); 292} 293if ($search_status != '' && $search_status > -1) { 294 $param .= "&search_status=".urlencode($search_status); 295} 296if ($filter) { 297 $param .= "&search_filter=".urlencode($filter); 298} 299if ($filtert) { 300 $param .= "&search_filtert=".urlencode($filtert); 301} 302if ($usergroup > 0) { 303 $param .= "&search_usergroup=".urlencode($usergroup); 304} 305if ($socid > 0) { 306 $param .= "&search_socid=".urlencode($socid); 307} 308if ($showbirthday) { 309 $param .= "&search_showbirthday=1"; 310} 311if ($pid) { 312 $param .= "&search_projectid=".urlencode($pid); 313} 314if ($type) { 315 $param .= "&search_type=".urlencode($type); 316} 317if ($search_id != '') { 318 $param .= '&search_title='.urlencode($search_id); 319} 320if ($search_title != '') { 321 $param .= '&search_title='.urlencode($search_title); 322} 323if ($search_note != '') { 324 $param .= '&search_note='.urlencode($search_note); 325} 326if (GETPOST('datestartday', 'int')) { 327 $param .= '&datestartday='.GETPOST('datestartday', 'int'); 328} 329if (GETPOST('datestartmonth', 'int')) { 330 $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int'); 331} 332if (GETPOST('datestartyear', 'int')) { 333 $param .= '&datestartyear='.GETPOST('datestartyear', 'int'); 334} 335if (GETPOST('dateendday', 'int')) { 336 $param .= '&dateendday='.GETPOST('dateendday', 'int'); 337} 338if (GETPOST('dateendmonth', 'int')) { 339 $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int'); 340} 341if (GETPOST('dateendyear', 'int')) { 342 $param .= '&dateendyear='.GETPOST('dateendyear', 'int'); 343} 344if ($optioncss != '') { 345 $param .= '&optioncss='.urlencode($optioncss); 346} 347// Add $param from extra fields 348include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; 349 350$paramnoactionodate = $param; 351 352// List of mass actions available 353$arrayofmassactions = array( 354 'set_all_events_to_todo' => $langs->trans("SetAllEventsToTodo"), 355 'set_all_events_to_in_progress' => $langs->trans("SetAllEventsToInProgress"), 356 'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"), 357); 358if ($user->rights->agenda->allactions->delete) { 359 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); 360} 361if ($user->rights->agenda->myactions->create) { 362 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); 363} 364if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { 365 $arrayofmassactions = array(); 366} 367$massactionbutton = $form->selectMassAction('', $arrayofmassactions); 368 369$sql = "SELECT"; 370if ($usergroup > 0) { 371 $sql .= " DISTINCT"; 372} 373$sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; 374$sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; 375$sql .= ' a.fk_user_author,a.fk_user_action,'; 376$sql .= " a.fk_contact, a.note, a.percent as percent,"; 377$sql .= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; 378$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,"; 379$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"; 380 381// Add fields from extrafields 382if (!empty($extrafields->attributes[$object->table_element]['label'])) { 383 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { 384 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); 385 } 386} 387 388// Add fields from hooks 389$parameters = array(); 390$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook 391$sql .= $hookmanager->resPrint; 392 393$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; 394$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object)"; 395if (!$user->rights->societe->client->voir && !$socid) { 396 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; 397} 398$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; 399$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; 400$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c"; 401// We must filter on resource table 402if ($resourceid > 0) { 403 $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; 404} 405// We must filter on assignement table 406if ($filtert > 0 || $usergroup > 0) { 407 $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; 408} 409if ($usergroup > 0) { 410 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; 411} 412$sql .= " WHERE c.id = a.fk_action"; 413$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; 414// Condition on actioncode 415if (!empty($actioncode)) { 416 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { 417 if ($actioncode == 'AC_NON_AUTO') { 418 $sql .= " AND c.type != 'systemauto'"; 419 } elseif ($actioncode == 'AC_ALL_AUTO') { 420 $sql .= " AND c.type = 'systemauto'"; 421 } else { 422 if ($actioncode == 'AC_OTH') { 423 $sql .= " AND c.type != 'systemauto'"; 424 } 425 if ($actioncode == 'AC_OTH_AUTO') { 426 $sql .= " AND c.type = 'systemauto'"; 427 } 428 } 429 } else { 430 if ($actioncode == 'AC_NON_AUTO') { 431 $sql .= " AND c.type != 'systemauto'"; 432 } elseif ($actioncode == 'AC_ALL_AUTO') { 433 $sql .= " AND c.type = 'systemauto'"; 434 } else { 435 if (is_array($actioncode)) { 436 $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")"; 437 } else { 438 $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")"; 439 } 440 } 441 } 442} 443if ($resourceid > 0) { 444 $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid); 445} 446if ($pid) { 447 $sql .= " AND a.fk_project=".((int) $pid); 448} 449if (!$user->rights->societe->client->voir && !$socid) { 450 $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")"; 451} 452if ($socid > 0) { 453 $sql .= " AND s.rowid = ".((int) $socid); 454} 455// We must filter on assignement table 456if ($filtert > 0 || $usergroup > 0) { 457 $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; 458} 459if ($type) { 460 $sql .= " AND c.id = ".((int) $type); 461} 462if ($search_status == '0') { 463 $sql .= " AND a.percent = 0"; 464} 465if ($search_status == 'na') { 466 $sql .= " AND a.percent = -1"; 467} // Not applicable 468if ($search_status == '50') { 469 $sql .= " AND (a.percent > 0 AND a.percent < 100)"; 470} // Running already started 471if ($search_status == '100') { 472 $sql .= " AND a.percent = 100"; 473} 474if ($search_status == 'done') { 475 $sql .= " AND (a.percent = 100)"; 476} 477if ($search_status == 'todo') { 478 $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; 479} 480if ($search_id) { 481 $sql .= natural_search("a.id", $search_id, 1); 482} 483if ($search_title) { 484 $sql .= natural_search("a.label", $search_title); 485} 486if ($search_note) { 487 $sql .= natural_search('a.note', $search_note); 488} 489// We must filter on assignement table 490if ($filtert > 0 || $usergroup > 0) { 491 $sql .= " AND ("; 492 if ($filtert > 0) { 493 $sql .= "(ar.fk_element = ".((int) $filtert)." OR (ar.fk_element IS NULL AND a.fk_user_action = ".((int) $filtert)."))"; // The OR is for backward compatibility 494 } 495 if ($usergroup > 0) { 496 $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup); 497 } 498 $sql .= ")"; 499} 500 501// The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) 502if ($dateselect > 0) { 503 $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)."'))"; 504} 505if ($datestart > 0) { 506 $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; 507} 508if ($dateend > 0) { 509 $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'"; 510} 511 512// Add where from extra fields 513include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; 514 515// Add where from hooks 516$parameters = array(); 517$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook 518$sql .= $hookmanager->resPrint; 519 520$sql .= $db->order($sortfield, $sortorder); 521 522$nbtotalofrecords = ''; 523if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { 524 // TODO Set and use an optimized request in $sqlforcount with no fields and no useless join to caluclate nb of records 525 $result = $db->query($sql); 526 $nbtotalofrecords = $db->num_rows($result); 527 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 528 $page = 0; 529 $offset = 0; 530 } 531} 532 533$sql .= $db->plimit($limit + 1, $offset); 534//print $sql; 535 536dol_syslog("comm/action/list.php", LOG_DEBUG); 537$resql = $db->query($sql); 538if ($resql) { 539 $actionstatic = new ActionComm($db); 540 $societestatic = new Societe($db); 541 542 $num = $db->num_rows($resql); 543 544 $arrayofselected = is_array($toselect) ? $toselect : array(); 545 546 // Local calendar 547 $newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">'; 548 $newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' '; 549 $newtitle .= '</div>'; 550 //$newtitle=$langs->trans($title); 551 552 $tabactive = 'cardlist'; 553 554 $head = calendars_prepare_head($param); 555 556 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n"; 557 558 if ($optioncss != '') { 559 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; 560 } 561 print '<input type="hidden" name="token" value="'.newToken().'">'; 562 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; 563 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; 564 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; 565 print '<input type="hidden" name="type" value="'.$type.'">'; 566 $nav = ''; 567 568 if ($filter) { 569 $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">'; 570 } 571 if ($showbirthday) { 572 $nav .= '<input type="hidden" name="search_showbirthday" value="1">'; 573 } 574 print $nav; 575 576 //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); 577 //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); 578 //print dol_get_fiche_end(); 579 580 // Add link to show birthdays 581 /* 582 $link = ''; 583 if (empty($conf->use_javascript_ajax)) 584 { 585 $newparam=$param; // newparam is for birthday links 586 $newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam); 587 if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1'; 588 $link='<a href="'.$_SERVER['PHP_SELF']; 589 $link.='?'.$newparam; 590 $link.='">'; 591 if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents"); 592 else $link.=$langs->trans("AgendaHideBirthdayEvents"); 593 $link.='</a>'; 594 } 595 */ 596 597 $s = $newtitle; 598 599 // Calendars from hooks 600 $parameters = array(); $object = null; 601 $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); 602 if (empty($reshook)) { 603 $s .= $hookmanager->resPrint; 604 } elseif ($reshook > 1) { 605 $s = $hookmanager->resPrint; 606 } 607 608 $viewmode = ''; 609 $viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">'; 610 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">'; 611 $viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="imgforviewmode pictoactionview block"'); 612 //$viewmode .= '</span>'; 613 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>'; 614 615 $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').$paramnoactionodate.'">'; 616 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">'; 617 $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"'); 618 //$viewmode .= '</span>'; 619 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>'; 620 621 $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').$paramnoactionodate.'">'; 622 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">'; 623 $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); 624 //$viewmode .= '</span>'; 625 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>'; 626 627 $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').$paramnoactionodate.'">'; 628 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">'; 629 $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); 630 //$viewmode .= '</span>'; 631 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>'; 632 633 $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').$paramnoactionodate.'">'; 634 //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">'; 635 $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); 636 //$viewmode .= '</span>'; 637 $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>'; 638 639 $viewmode .= '<span class="marginrightonly"></span>'; 640 641 // Add more views from hooks 642 $parameters = array(); $object = null; 643 $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); 644 if (empty($reshook)) { 645 $viewmode .= $hookmanager->resPrint; 646 } elseif ($reshook > 1) { 647 $viewmode = $hookmanager->resPrint; 648 } 649 650 $tmpforcreatebutton = dol_getdate(dol_now(), true); 651 652 $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; 653 654 //$param='month='.$monthshown.'&year='.$year; 655 $hourminsec = '100000'; 656 657 $url = DOL_URL_ROOT.'/comm/action/card.php?action=create'; 658 $url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec; 659 $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); 660 661 $newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create); 662 663 $param .= '&action='.$action; 664 665 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); 666 667 print $s; 668 669 $objecttmp = new ActionComm($db); 670 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; 671 672 $moreforfilter = ''; 673 674 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; 675 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields 676 if ($massactionbutton) { 677 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); 678 } 679 $i = 0; 680 681 print '<div class="liste_titre liste_titre_bydiv centpercent">'; 682 print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); 683 print '</div>'; 684 685 print '<div class="div-table-responsive">'; 686 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; 687 688 print '<tr class="liste_titre_filter">'; 689 if (!empty($arrayfields['a.id']['checked'])) { 690 print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>'; 691 } 692 if (!empty($arrayfields['owner']['checked'])) { 693 print '<td class="liste_titre"></td>'; 694 } 695 if (!empty($arrayfields['c.libelle']['checked'])) { 696 print '<td class="liste_titre"></td>'; 697 } 698 if (!empty($arrayfields['a.label']['checked'])) { 699 print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>'; 700 } 701 if (!empty($arrayfields['a.note']['checked'])) { 702 print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>'; 703 } 704 if (!empty($arrayfields['a.datep']['checked'])) { 705 print '<td class="liste_titre nowraponall" align="center">'; 706 print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); 707 print '</td>'; 708 } 709 if (!empty($arrayfields['a.datep2']['checked'])) { 710 print '<td class="liste_titre nowraponall" align="center">'; 711 print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); 712 print '</td>'; 713 } 714 if (!empty($arrayfields['s.nom']['checked'])) { 715 print '<td class="liste_titre"></td>'; 716 } 717 if (!empty($arrayfields['a.fk_contact']['checked'])) { 718 print '<td class="liste_titre"></td>'; 719 } 720 if (!empty($arrayfields['a.fk_element']['checked'])) { 721 print '<td class="liste_titre"></td>'; 722 } 723 724 // Extra fields 725 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; 726 727 // Fields from hook 728 $parameters = array('arrayfields'=>$arrayfields); 729 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook 730 print $hookmanager->resPrint; 731 732 if (!empty($arrayfields['a.datec']['checked'])) { 733 print '<td class="liste_titre"></td>'; 734 } 735 if (!empty($arrayfields['a.tms']['checked'])) { 736 print '<td class="liste_titre"></td>'; 737 } 738 if (!empty($arrayfields['a.percent']['checked'])) { 739 print '<td class="liste_titre center">'; 740 $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); 741 print ajax_combobox('selectsearch_status'); 742 print '</td>'; 743 } 744 // Action column 745 print '<td class="liste_titre" align="middle">'; 746 $searchpicto = $form->showFilterButtons(); 747 print $searchpicto; 748 print '</td>'; 749 print "</tr>\n"; 750 751 print '<tr class="liste_titre">'; 752 if (!empty($arrayfields['a.id']['checked'])) { 753 print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); 754 } 755 if (!empty($arrayfields['owner']['checked'])) { 756 print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); 757 } 758 if (!empty($arrayfields['c.libelle']['checked'])) { 759 print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); 760 } 761 if (!empty($arrayfields['a.label']['checked'])) { 762 print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); 763 } 764 if (!empty($arrayfields['a.note']['checked'])) { 765 print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); 766 } 767 //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) 768 if (!empty($arrayfields['a.datep']['checked'])) { 769 print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); 770 } 771 if (!empty($arrayfields['a.datep2']['checked'])) { 772 print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); 773 } 774 if (!empty($arrayfields['s.nom']['checked'])) { 775 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); 776 } 777 if (!empty($arrayfields['a.fk_contact']['checked'])) { 778 print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); 779 } 780 if (!empty($arrayfields['a.fk_element']['checked'])) { 781 print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); 782 } 783 784 // Extra fields 785 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; 786 787 // Hook fields 788 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); 789 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook 790 print $hookmanager->resPrint; 791 792 if (!empty($arrayfields['a.datec']['checked'])) { 793 print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); 794 } 795 if (!empty($arrayfields['a.tms']['checked'])) { 796 print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); 797 } 798 799 if (!empty($arrayfields['a.percent']['checked'])) { 800 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); 801 } 802 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); 803 print "</tr>\n"; 804 805 $contactstatic = new Contact($db); 806 $now = dol_now(); 807 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; 808 809 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; 810 $caction = new CActionComm($db); 811 $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); 812 $contactListCache = array(); 813 814 while ($i < min($num, $limit)) { 815 $obj = $db->fetch_object($resql); 816 817 // Discard auto action if option is on 818 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { 819 $i++; 820 continue; 821 } 822 823 $actionstatic->id = $obj->id; 824 $actionstatic->ref = $obj->id; 825 $actionstatic->code = $obj->code; 826 $actionstatic->type_code = $obj->type_code; 827 $actionstatic->type_label = $obj->type_label; 828 $actionstatic->type_picto = $obj->type_picto; 829 $actionstatic->type_color = $obj->type_color; 830 $actionstatic->label = $obj->label; 831 $actionstatic->location = $obj->location; 832 $actionstatic->note_private = dol_htmlentitiesbr($obj->note); 833 834 // Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid 835 // but only if we need it 836 if (!empty($arrayfields['a.fk_contact']['checked'])) { 837 $actionstatic->fetchResources(); 838 } 839 840 print '<tr class="oddeven">'; 841 842 // Ref 843 if (!empty($arrayfields['a.id']['checked'])) { 844 print '<td class="nowraponall">'; 845 print $actionstatic->getNomUrl(1, -1); 846 print '</td>'; 847 } 848 849 // User owner 850 if (!empty($arrayfields['owner']['checked'])) { 851 print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text. 852 if ($obj->fk_user_action > 0) { 853 $userstatic->fetch($obj->fk_user_action); 854 print $userstatic->getNomUrl(-1); 855 } else { 856 print ' '; 857 } 858 print '</td>'; 859 } 860 861 // Type 862 if (!empty($arrayfields['c.libelle']['checked'])) { 863 print '<td class="nowraponall">'; 864 print $actionstatic->getTypePicto(); 865 $labeltype = $obj->type_code; 866 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) { 867 $labeltype = 'AC_OTH'; 868 } 869 if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') { 870 $labeltype = $langs->trans("Message"); 871 } else { 872 if (!empty($arraylist[$labeltype])) { 873 $labeltype = $arraylist[$labeltype]; 874 } 875 if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) { 876 $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code 877 } 878 } 879 print dol_trunc($labeltype, 28); 880 print '</td>'; 881 } 882 883 // Label 884 if (!empty($arrayfields['a.label']['checked'])) { 885 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actionstatic->label).'">'; 886 print $actionstatic->label; 887 print '</td>'; 888 } 889 890 // Description 891 if (!empty($arrayfields['a.note']['checked'])) { 892 print '<td class="tdoverflowonsmartphone">'; 893 $text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 0)); 894 print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note_private); 895 print '</td>'; 896 } 897 898 $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour'; 899 900 // Start date 901 if (!empty($arrayfields['a.datep']['checked'])) { 902 print '<td class="center nowraponall">'; 903 print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); 904 $late = 0; 905 if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) { 906 $late = 1; 907 } 908 if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) { 909 $late = 1; 910 } 911 if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) { 912 $late = 1; 913 } 914 if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) { 915 $late = 1; 916 } 917 if ($late) { 918 print img_warning($langs->trans("Late")).' '; 919 } 920 print '</td>'; 921 } 922 923 // End date 924 if (!empty($arrayfields['a.datep2']['checked'])) { 925 print '<td class="center nowraponall">'; 926 print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuser'); 927 print '</td>'; 928 } 929 930 // Third party 931 if (!empty($arrayfields['s.nom']['checked'])) { 932 print '<td class="tdoverflowmax150">'; 933 if ($obj->socid > 0) { 934 $societestatic->id = $obj->socid; 935 $societestatic->client = $obj->client; 936 $societestatic->name = $obj->societe; 937 $societestatic->email = $obj->socemail; 938 939 print $societestatic->getNomUrl(1, '', 28); 940 } else { 941 print ' '; 942 } 943 print '</td>'; 944 } 945 946 // Contact 947 if (!empty($arrayfields['a.fk_contact']['checked'])) { 948 print '<td class="tdoverflowmax100">'; 949 950 if (!empty($actionstatic->socpeopleassigned)) { 951 $contactList = array(); 952 foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) { 953 if (!isset($contactListCache[$socpeopleassigned['id']])) { 954 // if no cache found we fetch it 955 $contact = new Contact($db); 956 if ($contact->fetch($socpeopleassigned['id']) > 0) { 957 $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); 958 $contactList[] = $contact->getNomUrl(1, '', 0); 959 } 960 } else { 961 // use cache 962 $contactList[] = $contactListCache[$socpeopleassigned['id']]; 963 } 964 } 965 if (!empty($contactList)) { 966 print implode(', ', $contactList); 967 } 968 } elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event 969 $contactstatic->id = $obj->fk_contact; 970 $contactstatic->email = $obj->email; 971 $contactstatic->lastname = $obj->lastname; 972 $contactstatic->firstname = $obj->firstname; 973 $contactstatic->phone_pro = $obj->phone_pro; 974 $contactstatic->phone_mobile = $obj->phone_mobile; 975 $contactstatic->phone_perso = $obj->phone_perso; 976 $contactstatic->country_id = $obj->country_id; 977 print $contactstatic->getNomUrl(1, '', 0); 978 } else { 979 print " "; 980 } 981 print '</td>'; 982 } 983 984 // Linked object 985 if (!empty($arrayfields['a.fk_element']['checked'])) { 986 print '<td class="tdoverflowmax150">'; 987 //var_dump($obj->fkelement.' '.$obj->elementtype); 988 if ($obj->fk_element > 0 && !empty($obj->elementtype)) { 989 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 990 print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); 991 } else { 992 print " "; 993 } 994 print '</td>'; 995 } 996 997 // Extra fields 998 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; 999 // Fields from hook 1000 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); 1001 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook 1002 print $hookmanager->resPrint; 1003 1004 // Date creation 1005 if (!empty($arrayfields['a.datec']['checked'])) { 1006 // Status/Percent 1007 print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuser').'</td>'; 1008 } 1009 // Date update 1010 if (!empty($arrayfields['a.tms']['checked'])) { 1011 print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuser').'</td>'; 1012 } 1013 if (!empty($arrayfields['a.percent']['checked'])) { 1014 // Status/Percent 1015 $datep = $db->jdate($obj->dp); 1016 print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'</td>'; 1017 } 1018 // Action column 1019 print '<td class="nowrap center">'; 1020 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined 1021 $selected = 0; 1022 if (in_array($obj->id, $arrayofselected)) { 1023 $selected = 1; 1024 } 1025 print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>'; 1026 } 1027 print '</td>'; 1028 1029 print "</tr>\n"; 1030 $i++; 1031 } 1032 print "</table>"; 1033 print '</div>'; 1034 print '</form>'; 1035 1036 $db->free($resql); 1037} else { 1038 dol_print_error($db); 1039} 1040 1041// End of page 1042llxFooter(); 1043$db->close(); 1044