list.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2006-2010 Regis Houssin <regis.houssin@capnetworks.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/projet/tasks/list.php
  21. * \ingroup project
  22. * \brief List all task of a project
  23. */
  24. require ("../../main.inc.php");
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  30. $langs->loadLangs(array('projects', 'users', 'companies'));
  31. $action=GETPOST('action','alpha');
  32. $massaction=GETPOST('massaction','alpha');
  33. $show_files=GETPOST('show_files','int');
  34. $confirm=GETPOST('confirm','alpha');
  35. $toselect = GETPOST('toselect', 'array');
  36. $id=GETPOST('id','int');
  37. $search_all=GETPOST('search_all', 'alphanohtml');
  38. $search_categ=GETPOST("search_categ",'alpha');
  39. $search_project=GETPOST('search_project');
  40. if (! isset($_GET['search_projectstatus']) && ! isset($_POST['search_projectstatus']))
  41. {
  42. if ($search_all != '') $search_projectstatus=-1;
  43. else $search_projectstatus=1;
  44. }
  45. else $search_projectstatus=GETPOST('search_projectstatus');
  46. $search_project_ref=GETPOST('search_project_ref');
  47. $search_project_title=GETPOST('search_project_title');
  48. $search_task_ref=GETPOST('search_task_ref');
  49. $search_task_label=GETPOST('search_task_label');
  50. $search_task_description=GETPOST('search_task_description');
  51. $search_project_user=GETPOST('search_project_user');
  52. $search_task_user=GETPOST('search_task_user');
  53. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  54. if ($mine) { $search_task_user = $user->id; $mine = 0; }
  55. $search_sday = GETPOST('search_sday','int');
  56. $search_smonth = GETPOST('search_smonth','int');
  57. $search_syear = GETPOST('search_syear','int');
  58. $search_eday = GETPOST('search_eday','int');
  59. $search_emonth = GETPOST('search_emonth','int');
  60. $search_eyear = GETPOST('search_eyear','int');
  61. // Initialize context for list
  62. $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'tasklist';
  63. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  64. $hookmanager->initHooks(array($contextpage));
  65. $extrafields = new ExtraFields($db);
  66. // fetch optionals attributes and labels
  67. $extralabels = $extrafields->fetch_name_optionals_label('projet_task');
  68. $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
  69. // Security check
  70. $socid=0;
  71. //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
  72. if (!$user->rights->projet->lire) accessforbidden();
  73. $diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id;
  74. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  75. $sortfield = GETPOST("sortfield",'alpha');
  76. $sortorder = GETPOST("sortorder",'alpha');
  77. $page = GETPOST("page",'int');
  78. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  79. $offset = $limit * $page;
  80. $pageprev = $page - 1;
  81. $pagenext = $page + 1;
  82. if (! $sortfield) $sortfield='p.ref';
  83. if (! $sortorder) $sortorder='DESC';
  84. // List of fields to search into when doing a "search in all"
  85. $fieldstosearchall = array(
  86. 't.ref'=>"Ref",
  87. 't.label'=>"Label",
  88. 't.description'=>"Description",
  89. 't.note_public'=>"NotePublic",
  90. );
  91. if (empty($user->socid)) $fieldstosearchall['t.note_private']="NotePrivate";
  92. $arrayfields=array(
  93. 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80),
  94. 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80),
  95. 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100),
  96. 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101),
  97. 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1),
  98. 'p.title'=>array('label'=>$langs->trans("ProjectLabel"), 'checked'=>0),
  99. 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>0),
  100. 'p.fk_statut'=>array('label'=>$langs->trans("ProjectStatus"), 'checked'=>1),
  101. 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>102),
  102. 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>103),
  103. 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>104),
  104. 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>105),
  105. 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  106. 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  107. //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  108. );
  109. // Extra fields
  110. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  111. {
  112. foreach($extrafields->attribute_label as $key => $val)
  113. {
  114. $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
  115. }
  116. }
  117. $object = new Task($db);
  118. /*
  119. * Actions
  120. */
  121. if (GETPOST('cancel')) { $action='list'; $massaction=''; }
  122. if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
  123. $parameters=array('socid'=>$socid);
  124. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  125. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  126. if (empty($reshook))
  127. {
  128. // Selection of new fields
  129. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  130. // Purge search criteria
  131. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
  132. {
  133. $search_all="";
  134. $search_categ="";
  135. $search_project="";
  136. $search_projectstatus=-1;
  137. $search_project_ref="";
  138. $search_project_title="";
  139. $search_task_ref="";
  140. $search_task_label="";
  141. $search_task_description="";
  142. $search_task_user=-1;
  143. $search_project_user=-1;
  144. $search_sday='';
  145. $search_smonth='';
  146. $search_syear='';
  147. $search_eday='';
  148. $search_emonth='';
  149. $search_eyear='';
  150. $toselect='';
  151. $search_array_options=array();
  152. }
  153. // Mass actions
  154. $objectclass='Task';
  155. $objectlabel='Tasks';
  156. $permtoread = $user->rights->projet->lire;
  157. $permtodelete = $user->rights->projet->supprimer;
  158. $uploaddir = $conf->projet->dir_output.'/tasks';
  159. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  160. }
  161. if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1;
  162. /*
  163. * View
  164. */
  165. $now = dol_now();
  166. $form=new Form($db);
  167. $formother=new FormOther($db);
  168. $socstatic=new Societe($db);
  169. $projectstatic = new Project($db);
  170. $puser=new User($db);
  171. $tuser=new User($db);
  172. if ($search_project_user > 0) $puser->fetch($search_project_user);
  173. if ($search_task_user > 0) $tuser->fetch($search_task_user);
  174. $title=$langs->trans("Activities");
  175. //if ($search_task_user == $user->id) $title=$langs->trans("MyActivities");
  176. if ($id)
  177. {
  178. $projectstatic->fetch($id);
  179. $projectstatic->societe->fetch($projectstatic->societe->id);
  180. }
  181. // Get list of project id allowed to user (in a string list separated by coma)
  182. if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid);
  183. //var_dump($projectsListId);
  184. // Get id of types of contacts for projects (This list never contains a lot of elements)
  185. $listofprojectcontacttype=array();
  186. $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
  187. $sql.= " WHERE ctc.element = '" . $projectstatic->element . "'";
  188. $sql.= " AND ctc.source = 'internal'";
  189. $resql = $db->query($sql);
  190. if ($resql)
  191. {
  192. while($obj = $db->fetch_object($resql))
  193. {
  194. $listofprojectcontacttype[$obj->rowid]=$obj->code;
  195. }
  196. }
  197. else dol_print_error($db);
  198. if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found
  199. // Get id of types of contacts for tasks (This list never contains a lot of elements)
  200. $listoftaskcontacttype=array();
  201. $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
  202. $sql.= " WHERE ctc.element = '" . $object->element . "'";
  203. $sql.= " AND ctc.source = 'internal'";
  204. $resql = $db->query($sql);
  205. if ($resql)
  206. {
  207. while($obj = $db->fetch_object($resql))
  208. {
  209. $listoftaskcontacttype[$obj->rowid]=$obj->code;
  210. }
  211. }
  212. else dol_print_error($db);
  213. if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found
  214. $distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
  215. $sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate";
  216. $sql.= ", s.nom as name, s.rowid as socid";
  217. $sql.= ", t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update";
  218. $sql.= ", t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut";
  219. // We'll need these fields in order to filter by categ
  220. if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project";
  221. // Add fields from extrafields
  222. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  223. // Add fields from hooks
  224. $parameters=array();
  225. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  226. $sql.=$hookmanager->resPrint;
  227. $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
  228. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
  229. // We'll need this table joined to the select in order to filter by categ
  230. if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ
  231. $sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
  232. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as ef on (t.rowid = ef.fk_object)";
  233. if ($search_project_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp";
  234. if ($search_task_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as ect";
  235. $sql.= " WHERE t.fk_projet = p.rowid";
  236. $sql.= " AND p.entity IN (".getEntity('project').')';
  237. if (! $user->rights->projet->all->lire) $sql.=" AND p.rowid IN (".($projectsListId?$projectsListId:'0').")"; // public and assigned to projects, or restricted to company for external users
  238. // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
  239. if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
  240. if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
  241. if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
  242. if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref);
  243. if ($search_project_title) $sql .= natural_search('p.title', $search_project_title);
  244. if ($search_task_ref) $sql .= natural_search('t.ref', $search_task_ref);
  245. if ($search_task_label) $sql .= natural_search('t.label', $search_task_label);
  246. if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
  247. if ($search_smonth > 0)
  248. {
  249. if ($search_syear > 0 && empty($search_sday))
  250. $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,$search_smonth,false))."' AND '".$db->idate(dol_get_last_day($search_syear,$search_smonth,false))."'";
  251. else if ($search_syear > 0 && ! empty($search_sday))
  252. $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_smonth, $search_sday, $search_syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_smonth, $search_sday, $search_syear))."'";
  253. else
  254. $sql.= " AND date_format(t.dateo, '%m') = '".$search_smonth."'";
  255. }
  256. else if ($search_syear > 0)
  257. {
  258. $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,1,false))."' AND '".$db->idate(dol_get_last_day($search_syear,12,false))."'";
  259. }
  260. if ($search_emonth > 0)
  261. {
  262. if ($search_eyear > 0 && empty($search_eday))
  263. $sql.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,$search_emonth,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,$search_emonth,false))."'";
  264. else if ($search_eyear > 0 && ! empty($search_eday))
  265. $sql.= " AND t.datee BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_emonth, $search_eday, $search_eyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_emonth, $search_eday, $search_eyear))."'";
  266. else
  267. $sql.= " AND date_format(t.datee, '%m') = '".$search_emonth."'";
  268. }
  269. else if ($search_eyear > 0)
  270. {
  271. $sql.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,12,false))."'";
  272. }
  273. if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  274. if ($search_projectstatus >= 0)
  275. {
  276. if ($search_projectstatus == 99) $sql .= " AND p.fk_statut <> 2";
  277. else $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus);
  278. }
  279. if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public);
  280. if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user;
  281. if ($search_task_user > 0) $sql.= " AND ect.fk_c_type_contact IN (".join(',',array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user;
  282. // Add where from extra fields
  283. foreach ($search_array_options as $key => $val)
  284. {
  285. $crit=$val;
  286. $tmpkey=preg_replace('/search_options_/','',$key);
  287. $typ=$extrafields->attribute_type[$tmpkey];
  288. $mode=0;
  289. if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
  290. if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
  291. {
  292. $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
  293. }
  294. }
  295. // Add where from hooks
  296. $parameters=array();
  297. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  298. $sql.=$hookmanager->resPrint;
  299. $sql.= $db->order($sortfield,$sortorder);
  300. $nbtotalofrecords = '';
  301. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  302. {
  303. $result = $db->query($sql);
  304. $nbtotalofrecords = $db->num_rows($result);
  305. }
  306. $sql.= $db->plimit($limit + 1,$offset);
  307. //print $sql;
  308. dol_syslog("list allowed project", LOG_DEBUG);
  309. //print $sql;
  310. $resql = $db->query($sql);
  311. if (! $resql)
  312. {
  313. dol_print_error($db);
  314. exit;
  315. }
  316. $num = $db->num_rows($resql);
  317. $arrayofselected=is_array($toselect)?$toselect:array();
  318. if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
  319. {
  320. $obj = $db->fetch_object($resql);
  321. $id = $obj->id;
  322. header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1');
  323. exit;
  324. }
  325. $help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  326. llxHeader("", $title, $help_url);
  327. $param='';
  328. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  329. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  330. if ($search_sday) $param.='&search_sday='.$search_sday;
  331. if ($search_smonth) $param.='&search_smonth='.$search_smonth;
  332. if ($search_syear) $param.='&search_syear=' .$search_syear;
  333. if ($search_eday) $param.='&search_eday='.$search_eday;
  334. if ($search_emonth) $param.='&search_emonth='.$search_emonth;
  335. if ($search_eyear) $param.='&search_eyear=' .$search_eyear;
  336. if ($socid) $param.='&socid='.$socid;
  337. if ($search_all != '') $param.='&search_all='.$search_all;
  338. if ($search_project_ref != '') $param.='&search_project_ref='.$search_project_ref;
  339. if ($search_project_title != '') $param.='&search_project_title='.$search_project_title;
  340. if ($search_ref != '') $param.='&search_ref='.$search_ref;
  341. if ($search_label != '') $param.='&search_label='.$search_label;
  342. if ($search_societe != '') $param.='&search_societe='.$search_societe;
  343. if ($search_projectstatus != '') $param.='&search_projectstatus='.$search_projectstatus;
  344. if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','none'))) $param.='&search_opp_status='.urlencode($search_opp_status);
  345. if ($search_public != '') $param.='&search_public='.$search_public;
  346. if ($search_project_user != '') $param.='&search_project_user='.$search_project_user;
  347. if ($search_task_user > 0) $param.='&search_task_user='.$search_task_user;
  348. if ($optioncss != '') $param.='&optioncss='.$optioncss;
  349. // Add $param from extra fields
  350. foreach ($search_array_options as $key => $val)
  351. {
  352. $crit=$val;
  353. $tmpkey=preg_replace('/search_options_/','',$key);
  354. if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
  355. }
  356. // List of mass actions available
  357. $arrayofmassactions = array(
  358. // 'presend'=>$langs->trans("SendByMail"),
  359. // 'builddoc'=>$langs->trans("PDFMerge"),
  360. );
  361. //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
  362. if ($user->rights->societe->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
  363. if ($massaction == 'presend') $arrayofmassactions=array();
  364. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  365. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  366. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  367. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  368. print '<input type="hidden" name="action" value="list">';
  369. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  370. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  371. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  372. print '<input type="hidden" name="page" value="'.$page.'">';
  373. print '<input type="hidden" name="type" value="'.$type.'">';
  374. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  375. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit);
  376. // Show description of content
  377. if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'<br><br>';
  378. else
  379. {
  380. if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksOnProjectsDesc").'<br><br>';
  381. else print $langs->trans("TasksOnProjectsPublicDesc").'<br><br>';
  382. }
  383. if ($search_all)
  384. {
  385. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  386. print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
  387. }
  388. $morehtmlfilter = '';
  389. // Filter on categories
  390. if (! empty($conf->categorie->enabled))
  391. {
  392. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  393. $moreforfilter.='<div class="divsearchfield">';
  394. $moreforfilter.=$langs->trans('ProjectCategories'). ': ';
  395. $moreforfilter.=$formother->select_categories('project',$search_categ,'search_categ',1);
  396. $moreforfilter.='</div>';
  397. }
  398. // If the user can view users
  399. $moreforfilter.='<div class="divsearchfield">';
  400. $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' ';
  401. $includeonly='';
  402. if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
  403. $moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300');
  404. $moreforfilter.='</div>';
  405. // If the user can view users
  406. $moreforfilter.='<div class="divsearchfield">';
  407. $moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': ';
  408. $includeonly='';
  409. if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
  410. $moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300');
  411. $moreforfilter.='</div>';
  412. if (! empty($moreforfilter))
  413. {
  414. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  415. print $moreforfilter;
  416. $parameters=array();
  417. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  418. print $hookmanager->resPrint;
  419. print '</div>';
  420. }
  421. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  422. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  423. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  424. print '<div class="div-table-responsive">';
  425. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
  426. print '<tr class="liste_titre_filter">';
  427. if (! empty($arrayfields['t.ref']['checked']))
  428. {
  429. print '<td class="liste_titre">';
  430. print '<input type="text" class="flat" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'" size="4">';
  431. print '</td>';
  432. }
  433. if (! empty($arrayfields['t.label']['checked']))
  434. {
  435. print '<td class="liste_titre">';
  436. print '<input type="text" class="flat" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'" size="8">';
  437. print '</td>';
  438. }
  439. // Start date
  440. if (! empty($arrayfields['t.dateo']['checked']))
  441. {
  442. print '<td class="liste_titre center">';
  443. if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.$search_sday.'">';
  444. print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.$search_smonth.'">';
  445. $formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5);
  446. print '</td>';
  447. }
  448. // End date
  449. if (! empty($arrayfields['t.datee']['checked']))
  450. {
  451. print '<td class="liste_titre center">';
  452. if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.$search_eday.'">';
  453. print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.$search_emonth.'">';
  454. $formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5);
  455. print '</td>';
  456. }
  457. if (! empty($arrayfields['p.ref']['checked']))
  458. {
  459. print '<td class="liste_titre">';
  460. print '<input type="text" class="flat" name="search_project_ref" value="'.$search_project_ref.'" size="4">';
  461. print '</td>';
  462. }
  463. if (! empty($arrayfields['p.title']['checked']))
  464. {
  465. print '<td class="liste_titre">';
  466. print '<input type="text" class="flat" name="search_project_title" value="'.$search_project_title.'" size="6">';
  467. print '</td>';
  468. }
  469. if (! empty($arrayfields['s.nom']['checked']))
  470. {
  471. print '<td class="liste_titre">';
  472. print '<input type="text" class="flat" name="search_societe" value="'.dol_escape_htmltag($search_societe).'" size="4">';
  473. print '</td>';
  474. }
  475. if (! empty($arrayfields['p.fk_statut']['checked']))
  476. {
  477. print '<td class="liste_titre center">';
  478. $arrayofstatus = array();
  479. foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val);
  480. $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')';
  481. print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
  482. print '</td>';
  483. }
  484. if (! empty($arrayfields['t.planned_workload']['checked'])) print '<td class="liste_titre"></td>';
  485. if (! empty($arrayfields['t.duration_effective']['checked'])) print '<td class="liste_titre"></td>';
  486. if (! empty($arrayfields['t.progress_calculated']['checked'])) print '<td class="liste_titre"></td>';
  487. if (! empty($arrayfields['t.progress']['checked'])) print '<td class="liste_titre"></td>';
  488. // Extra fields
  489. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  490. {
  491. foreach($extrafields->attribute_label as $key => $val)
  492. {
  493. if (! empty($arrayfields["ef.".$key]['checked']))
  494. {
  495. $align=$extrafields->getAlignFlag($key);
  496. $typeofextrafield=$extrafields->attribute_type[$key];
  497. print '<td class="liste_titre'.($align?' '.$align:'').'">';
  498. if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
  499. {
  500. $crit=$val;
  501. $tmpkey=preg_replace('/search_options_/','',$key);
  502. $searchclass='';
  503. if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
  504. if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
  505. print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
  506. }
  507. print '</td>';
  508. }
  509. }
  510. }
  511. // Fields from hook
  512. $parameters=array('arrayfields'=>$arrayfields);
  513. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  514. print $hookmanager->resPrint;
  515. if (! empty($arrayfields['t.datec']['checked']))
  516. {
  517. // Date creation
  518. print '<td class="liste_titre">';
  519. print '</td>';
  520. }
  521. if (! empty($arrayfields['t.tms']['checked']))
  522. {
  523. // Date modification
  524. print '<td class="liste_titre">';
  525. print '</td>';
  526. }
  527. // Action column
  528. print '<td class="liste_titre" align="right">';
  529. $searchpicto=$form->showFilterButtons();
  530. print $searchpicto;
  531. print '</td>';
  532. print "</tr>\n";
  533. print '<tr class="liste_titre">';
  534. if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder);
  535. if (! empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'],$_SERVER["PHP_SELF"],"t.label","",$param,"",$sortfield,$sortorder);
  536. if (! empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'],$_SERVER["PHP_SELF"],"t.dateo","",$param,'align="center"',$sortfield,$sortorder);
  537. if (! empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'],$_SERVER["PHP_SELF"],"t.datee","",$param,'align="center"',$sortfield,$sortorder);
  538. if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder);
  539. if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder);
  540. if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
  541. if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="center"',$sortfield,$sortorder);
  542. if (! empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'],$_SERVER["PHP_SELF"],"t.planned_workload","",$param,'align="center"',$sortfield,$sortorder);
  543. if (! empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'],$_SERVER["PHP_SELF"],"t.duration_effective","",$param,'align="center"',$sortfield,$sortorder);
  544. if (! empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'],$_SERVER["PHP_SELF"],"","",$param,'align="center"');
  545. if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'],$_SERVER["PHP_SELF"],"t.progress","",$param,'align="center"',$sortfield,$sortorder);
  546. // Extra fields
  547. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  548. {
  549. foreach($extrafields->attribute_label as $key => $val)
  550. {
  551. if (! empty($arrayfields["ef.".$key]['checked']))
  552. {
  553. $align=$extrafields->getAlignFlag($key);
  554. $sortonfield = "ef.".$key;
  555. if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
  556. print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
  557. }
  558. }
  559. }
  560. // Hook fields
  561. $parameters=array('arrayfields'=>$arrayfields);
  562. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  563. print $hookmanager->resPrint;
  564. if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  565. if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  566. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  567. print "</tr>\n";
  568. $plannedworkloadoutputformat='allhourmin';
  569. $timespentoutputformat='allhourmin';
  570. if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
  571. if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT;
  572. $i=0;
  573. $totalarray=array();
  574. while ($i < min($num,$limit))
  575. {
  576. $obj = $db->fetch_object($resql);
  577. $object->id = $obj->id;
  578. $object->ref = $obj->ref;
  579. $object->label = $obj->label;
  580. $object->fk_statut = $obj->fk_statut;
  581. $object->progress = $obj->progress;
  582. $object->datee = $db->jdate($obj->date_end); // deprecated
  583. $object->date_end = $db->jdate($obj->date_end);
  584. $projectstatic->id = $obj->projectid;
  585. $projectstatic->ref = $obj->projectref;
  586. $projectstatic->title = $obj->projecttitle;
  587. $projectstatic->public = $obj->public;
  588. $projectstatic->statut = $obj->projectstatus;
  589. $projectstatic->datee = $db->jdate($obj->projectdatee);
  590. $userAccess = $projectstatic->restrictedProjectArea($user); // why this ?
  591. if ($userAccess >= 0)
  592. {
  593. print '<tr class="oddeven">';
  594. // Ref
  595. if (! empty($arrayfields['t.ref']['checked']))
  596. {
  597. print '<td>';
  598. print $object->getNomUrl(1,'withproject');
  599. if ($object->hasDelay()) print img_warning("Late");
  600. print '</td>';
  601. if (! $i) $totalarray['nbfield']++;
  602. }
  603. // Label
  604. if (! empty($arrayfields['t.label']['checked']))
  605. {
  606. print '<td>';
  607. print $object->label;
  608. print '</td>';
  609. if (! $i) $totalarray['nbfield']++;
  610. }
  611. // Date start
  612. if (! empty($arrayfields['t.dateo']['checked']))
  613. {
  614. print '<td class="center">';
  615. print dol_print_date($db->jdate($obj->date_start),'day');
  616. print '</td>';
  617. if (! $i) $totalarray['nbfield']++;
  618. }
  619. // Date end
  620. if (! empty($arrayfields['t.datee']['checked']))
  621. {
  622. print '<td class="center">';
  623. print dol_print_date($db->jdate($obj->date_end),'day');
  624. print '</td>';
  625. if (! $i) $totalarray['nbfield']++;
  626. }
  627. // Project ref
  628. if (! empty($arrayfields['p.ref']['checked']))
  629. {
  630. print '<td class="nowrap">';
  631. print $projectstatic->getNomUrl(1, 'task');
  632. if ($projectstatic->hasDelay()) print img_warning("Late");
  633. print '</td>';
  634. if (! $i) $totalarray['nbfield']++;
  635. }
  636. // Project title
  637. if (! empty($arrayfields['p.title']['checked']))
  638. {
  639. print '<td>';
  640. print dol_trunc($obj->projecttitle,80);
  641. print '</td>';
  642. if (! $i) $totalarray['nbfield']++;
  643. }
  644. // Third party
  645. if (! empty($arrayfields['s.nom']['checked']))
  646. {
  647. print '<td>';
  648. if ($obj->socid)
  649. {
  650. $socstatic->id=$obj->socid;
  651. $socstatic->name=$obj->name;
  652. print $socstatic->getNomUrl(1);
  653. }
  654. else
  655. {
  656. print '&nbsp;';
  657. }
  658. print '</td>';
  659. if (! $i) $totalarray['nbfield']++;
  660. }
  661. // Project status
  662. if (! empty($arrayfields['p.fk_statut']['checked']))
  663. {
  664. print '<td align="center">';
  665. print $projectstatic->getLibStatut(1);
  666. print '</td>';
  667. if (! $i) $totalarray['nbfield']++;
  668. }
  669. // Planned workload
  670. if (! empty($arrayfields['t.planned_workload']['checked']))
  671. {
  672. print '<td class="center">';
  673. $fullhour=convertSecondToTime($obj->planned_workload,$plannedworkloadoutputformat);
  674. $workingdelay=convertSecondToTime($obj->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
  675. if ($obj->planned_workload != '')
  676. {
  677. print $fullhour;
  678. // TODO Add delay taking account of working hours per day and working day per week
  679. //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')';
  680. }
  681. //else print '--:--';
  682. print '</td>';
  683. if (! $i) $totalarray['nbfield']++;
  684. if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield'];
  685. $totalarray['totalplannedworkload'] += $obj->planned_workload;
  686. }
  687. // Time spent
  688. if (! empty($arrayfields['t.duration_effective']['checked']))
  689. {
  690. $showlineingray=0;$showproject=1;
  691. print '<td class="center">';
  692. if ($showlineingray) print '<i>';
  693. else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
  694. if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat);
  695. else print '--:--';
  696. if ($showlineingray) print '</i>';
  697. else print '</a>';
  698. print '</td>';
  699. if (! $i) $totalarray['nbfield']++;
  700. if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield'];
  701. $totalarray['totaldurationeffective'] += $obj->duration_effective;
  702. }
  703. // Calculated progress
  704. if (! empty($arrayfields['t.progress_calculated']['checked']))
  705. {
  706. print '<td class="center">';
  707. if ($obj->planned_workload || $obj->duration_effective)
  708. {
  709. if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload,2).' %';
  710. else print $form->textwithpicto('',$langs->trans('WorkloadNotDefined'), 1, 'help');
  711. }
  712. print '</td>';
  713. if (! $i) $totalarray['nbfield']++;
  714. if (! $i) $totalarray['totalprogress_calculated']=$totalarray['nbfield'];
  715. }
  716. // Declared progress
  717. if (! empty($arrayfields['t.progress']['checked']))
  718. {
  719. print '<td class="center">';
  720. if ($obj->progress != '')
  721. {
  722. print $obj->progress.' %';
  723. }
  724. print '</td>';
  725. if (! $i) $totalarray['nbfield']++;
  726. }
  727. // Extra fields
  728. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  729. {
  730. foreach($extrafields->attribute_label as $key => $val)
  731. {
  732. if (! empty($arrayfields["ef.".$key]['checked']))
  733. {
  734. print '<td';
  735. $align=$extrafields->getAlignFlag($key);
  736. if ($align) print ' align="'.$align.'"';
  737. print '>';
  738. $tmpkey='options_'.$key;
  739. print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
  740. print '</td>';
  741. if (! $i) $totalarray['nbfield']++;
  742. }
  743. }
  744. }
  745. // Fields from hook
  746. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  747. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  748. print $hookmanager->resPrint;
  749. // Date creation
  750. if (! empty($arrayfields['t.datec']['checked']))
  751. {
  752. print '<td align="center">';
  753. print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
  754. print '</td>';
  755. if (! $i) $totalarray['nbfield']++;
  756. }
  757. // Date modification
  758. if (! empty($arrayfields['t.tms']['checked']))
  759. {
  760. print '<td align="center">';
  761. print dol_print_date($db->jdate($obj->date_update), 'dayhour');
  762. print '</td>';
  763. if (! $i) $totalarray['nbfield']++;
  764. }
  765. // Status
  766. /*if (! empty($arrayfields['p.fk_statut']['checked']))
  767. {
  768. $projectstatic->statut = $obj->fk_statut;
  769. print '<td align="right">'.$projectstatic->getLibStatut(5).'</td>';
  770. }*/
  771. // Action column
  772. print '<td class="nowrap" align="center">';
  773. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  774. {
  775. $selected=0;
  776. if (in_array($obj->id, $arrayofselected)) $selected=1;
  777. print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected?' checked="checked"':'').'>';
  778. }
  779. print '</td>';
  780. if (! $i) $totalarray['nbfield']++;
  781. print "</tr>\n";
  782. //print projectLinesa();
  783. }
  784. $i++;
  785. }
  786. // Show total line
  787. if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield']))
  788. {
  789. print '<tr class="liste_total">';
  790. $i=0;
  791. while ($i < $totalarray['nbfield'])
  792. {
  793. $i++;
  794. if ($i == 1)
  795. {
  796. if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
  797. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  798. }
  799. elseif ($totalarray['totalplannedworkloadfield'] == $i) print '<td align="center">'.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).'</td>';
  800. elseif ($totalarray['totaldurationeffectivefield'] == $i) print '<td align="center">'.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).'</td>';
  801. elseif ($totalarray['totalprogress_calculated'] == $i) print '<td align="center">'.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').'</td>';
  802. else print '<td></td>';
  803. }
  804. print '</tr>';
  805. }
  806. $db->free($resql);
  807. $parameters=array('sql' => $sql);
  808. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  809. print $hookmanager->resPrint;
  810. print "</table>";
  811. print '</div>';
  812. print '</form>';
  813. llxFooter();
  814. $db->close();