list.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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 page. Note that conf->hooks_modules contains array of hook context
  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. if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
  115. }
  116. }
  117. $object = new Task($db);
  118. /*
  119. * Actions
  120. */
  121. if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
  122. if (! GETPOST('confirmmassaction','alpha') && $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','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // 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_search=0;
  289. if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric
  290. if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int
  291. if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1'))
  292. {
  293. $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search);
  294. }
  295. }
  296. // Add where from hooks
  297. $parameters=array();
  298. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  299. $sql.=$hookmanager->resPrint;
  300. $sql.= $db->order($sortfield,$sortorder);
  301. $nbtotalofrecords = '';
  302. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  303. {
  304. $result = $db->query($sql);
  305. $nbtotalofrecords = $db->num_rows($result);
  306. }
  307. $sql.= $db->plimit($limit + 1,$offset);
  308. //print $sql;
  309. dol_syslog("list allowed project", LOG_DEBUG);
  310. //print $sql;
  311. $resql = $db->query($sql);
  312. if (! $resql)
  313. {
  314. dol_print_error($db);
  315. exit;
  316. }
  317. $num = $db->num_rows($resql);
  318. $arrayofselected=is_array($toselect)?$toselect:array();
  319. if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
  320. {
  321. $obj = $db->fetch_object($resql);
  322. $id = $obj->id;
  323. header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1');
  324. exit;
  325. }
  326. $help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  327. llxHeader("", $title, $help_url);
  328. $param='';
  329. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  330. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  331. if ($search_sday) $param.='&search_sday='.$search_sday;
  332. if ($search_smonth) $param.='&search_smonth='.$search_smonth;
  333. if ($search_syear) $param.='&search_syear=' .$search_syear;
  334. if ($search_eday) $param.='&search_eday='.$search_eday;
  335. if ($search_emonth) $param.='&search_emonth='.$search_emonth;
  336. if ($search_eyear) $param.='&search_eyear=' .$search_eyear;
  337. if ($socid) $param.='&socid='.$socid;
  338. if ($search_all != '') $param.='&search_all='.$search_all;
  339. if ($search_project_ref != '') $param.='&search_project_ref='.$search_project_ref;
  340. if ($search_project_title != '') $param.='&search_project_title='.$search_project_title;
  341. if ($search_ref != '') $param.='&search_ref='.$search_ref;
  342. if ($search_label != '') $param.='&search_label='.$search_label;
  343. if ($search_societe != '') $param.='&search_societe='.$search_societe;
  344. if ($search_projectstatus != '') $param.='&search_projectstatus='.$search_projectstatus;
  345. 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);
  346. if ($search_public != '') $param.='&search_public='.$search_public;
  347. if ($search_project_user != '') $param.='&search_project_user='.$search_project_user;
  348. if ($search_task_user > 0) $param.='&search_task_user='.$search_task_user;
  349. if ($optioncss != '') $param.='&optioncss='.$optioncss;
  350. // Add $param from extra fields
  351. foreach ($search_array_options as $key => $val)
  352. {
  353. $crit=$val;
  354. $tmpkey=preg_replace('/search_options_/','',$key);
  355. if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
  356. }
  357. // List of mass actions available
  358. $arrayofmassactions = array(
  359. // 'presend'=>$langs->trans("SendByMail"),
  360. // 'builddoc'=>$langs->trans("PDFMerge"),
  361. );
  362. //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
  363. if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
  364. if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
  365. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  366. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  367. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  368. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  369. print '<input type="hidden" name="action" value="list">';
  370. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  371. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  372. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  373. print '<input type="hidden" name="page" value="'.$page.'">';
  374. print '<input type="hidden" name="type" value="'.$type.'">';
  375. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  376. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit);
  377. // Show description of content
  378. if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'<br><br>';
  379. else
  380. {
  381. if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksOnProjectsDesc").'<br><br>';
  382. else print $langs->trans("TasksOnProjectsPublicDesc").'<br><br>';
  383. }
  384. $topicmail="Information";
  385. $modelmail="task";
  386. $objecttmp=new Task($db);
  387. $trackid='tas'.$object->id;
  388. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  389. if ($search_all)
  390. {
  391. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  392. print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
  393. }
  394. $morehtmlfilter = '';
  395. // Filter on categories
  396. if (! empty($conf->categorie->enabled))
  397. {
  398. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  399. $moreforfilter.='<div class="divsearchfield">';
  400. $moreforfilter.=$langs->trans('ProjectCategories'). ': ';
  401. $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300');
  402. $moreforfilter.='</div>';
  403. }
  404. // If the user can view users
  405. $moreforfilter.='<div class="divsearchfield">';
  406. $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' ';
  407. $includeonly='';
  408. if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
  409. $moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200');
  410. $moreforfilter.='</div>';
  411. // If the user can view users
  412. $moreforfilter.='<div class="divsearchfield">';
  413. $moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': ';
  414. $includeonly='';
  415. if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
  416. $moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200');
  417. $moreforfilter.='</div>';
  418. if (! empty($moreforfilter))
  419. {
  420. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  421. print $moreforfilter;
  422. $parameters=array();
  423. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  424. print $hookmanager->resPrint;
  425. print '</div>';
  426. }
  427. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  428. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  429. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  430. print '<div class="div-table-responsive">';
  431. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
  432. print '<tr class="liste_titre_filter">';
  433. if (! empty($arrayfields['t.ref']['checked']))
  434. {
  435. print '<td class="liste_titre">';
  436. print '<input type="text" class="flat" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'" size="4">';
  437. print '</td>';
  438. }
  439. if (! empty($arrayfields['t.label']['checked']))
  440. {
  441. print '<td class="liste_titre">';
  442. print '<input type="text" class="flat" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'" size="8">';
  443. print '</td>';
  444. }
  445. // Start date
  446. if (! empty($arrayfields['t.dateo']['checked']))
  447. {
  448. print '<td class="liste_titre center">';
  449. 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.'">';
  450. print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.$search_smonth.'">';
  451. $formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5);
  452. print '</td>';
  453. }
  454. // End date
  455. if (! empty($arrayfields['t.datee']['checked']))
  456. {
  457. print '<td class="liste_titre center">';
  458. 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.'">';
  459. print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.$search_emonth.'">';
  460. $formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5);
  461. print '</td>';
  462. }
  463. if (! empty($arrayfields['p.ref']['checked']))
  464. {
  465. print '<td class="liste_titre">';
  466. print '<input type="text" class="flat" name="search_project_ref" value="'.$search_project_ref.'" size="4">';
  467. print '</td>';
  468. }
  469. if (! empty($arrayfields['p.title']['checked']))
  470. {
  471. print '<td class="liste_titre">';
  472. print '<input type="text" class="flat" name="search_project_title" value="'.$search_project_title.'" size="6">';
  473. print '</td>';
  474. }
  475. if (! empty($arrayfields['s.nom']['checked']))
  476. {
  477. print '<td class="liste_titre">';
  478. print '<input type="text" class="flat" name="search_societe" value="'.dol_escape_htmltag($search_societe).'" size="4">';
  479. print '</td>';
  480. }
  481. if (! empty($arrayfields['p.fk_statut']['checked']))
  482. {
  483. print '<td class="liste_titre center">';
  484. $arrayofstatus = array();
  485. foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val);
  486. $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')';
  487. print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
  488. print '</td>';
  489. }
  490. if (! empty($arrayfields['t.planned_workload']['checked'])) print '<td class="liste_titre"></td>';
  491. if (! empty($arrayfields['t.duration_effective']['checked'])) print '<td class="liste_titre"></td>';
  492. if (! empty($arrayfields['t.progress_calculated']['checked'])) print '<td class="liste_titre"></td>';
  493. if (! empty($arrayfields['t.progress']['checked'])) print '<td class="liste_titre"></td>';
  494. // Extra fields
  495. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  496. {
  497. foreach($extrafields->attribute_label as $key => $val)
  498. {
  499. if (! empty($arrayfields["ef.".$key]['checked']))
  500. {
  501. $align=$extrafields->getAlignFlag($key);
  502. $typeofextrafield=$extrafields->attribute_type[$key];
  503. print '<td class="liste_titre'.($align?' '.$align:'').'">';
  504. if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
  505. {
  506. $crit=$val;
  507. $tmpkey=preg_replace('/search_options_/','',$key);
  508. $searchclass='';
  509. if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
  510. if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
  511. print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
  512. }
  513. print '</td>';
  514. }
  515. }
  516. }
  517. // Fields from hook
  518. $parameters=array('arrayfields'=>$arrayfields);
  519. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  520. print $hookmanager->resPrint;
  521. if (! empty($arrayfields['t.datec']['checked']))
  522. {
  523. // Date creation
  524. print '<td class="liste_titre">';
  525. print '</td>';
  526. }
  527. if (! empty($arrayfields['t.tms']['checked']))
  528. {
  529. // Date modification
  530. print '<td class="liste_titre">';
  531. print '</td>';
  532. }
  533. // Action column
  534. print '<td class="liste_titre" align="right">';
  535. $searchpicto=$form->showFilterButtons();
  536. print $searchpicto;
  537. print '</td>';
  538. print "</tr>\n";
  539. print '<tr class="liste_titre">';
  540. if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder);
  541. if (! empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'],$_SERVER["PHP_SELF"],"t.label","",$param,"",$sortfield,$sortorder);
  542. if (! empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'],$_SERVER["PHP_SELF"],"t.dateo","",$param,'align="center"',$sortfield,$sortorder);
  543. if (! empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'],$_SERVER["PHP_SELF"],"t.datee","",$param,'align="center"',$sortfield,$sortorder);
  544. if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder);
  545. if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder);
  546. if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
  547. 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);
  548. 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);
  549. 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);
  550. if (! empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'],$_SERVER["PHP_SELF"],"","",$param,'align="center"');
  551. if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'],$_SERVER["PHP_SELF"],"t.progress","",$param,'align="center"',$sortfield,$sortorder);
  552. // Extra fields
  553. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  554. {
  555. foreach($extrafields->attribute_label as $key => $val)
  556. {
  557. if (! empty($arrayfields["ef.".$key]['checked']))
  558. {
  559. $align=$extrafields->getAlignFlag($key);
  560. $sortonfield = "ef.".$key;
  561. if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
  562. print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
  563. }
  564. }
  565. }
  566. // Hook fields
  567. $parameters=array('arrayfields'=>$arrayfields);
  568. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  569. print $hookmanager->resPrint;
  570. 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);
  571. 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);
  572. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  573. print "</tr>\n";
  574. $plannedworkloadoutputformat='allhourmin';
  575. $timespentoutputformat='allhourmin';
  576. if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
  577. if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT;
  578. $i=0;
  579. $totalarray=array();
  580. while ($i < min($num,$limit))
  581. {
  582. $obj = $db->fetch_object($resql);
  583. $object->id = $obj->id;
  584. $object->ref = $obj->ref;
  585. $object->label = $obj->label;
  586. $object->fk_statut = $obj->fk_statut;
  587. $object->progress = $obj->progress;
  588. $object->datee = $db->jdate($obj->date_end); // deprecated
  589. $object->date_end = $db->jdate($obj->date_end);
  590. $projectstatic->id = $obj->projectid;
  591. $projectstatic->ref = $obj->projectref;
  592. $projectstatic->title = $obj->projecttitle;
  593. $projectstatic->public = $obj->public;
  594. $projectstatic->statut = $obj->projectstatus;
  595. $projectstatic->datee = $db->jdate($obj->projectdatee);
  596. $userAccess = $projectstatic->restrictedProjectArea($user); // why this ?
  597. if ($userAccess >= 0)
  598. {
  599. print '<tr class="oddeven">';
  600. // Ref
  601. if (! empty($arrayfields['t.ref']['checked']))
  602. {
  603. print '<td>';
  604. print $object->getNomUrl(1,'withproject');
  605. if ($object->hasDelay()) print img_warning("Late");
  606. print '</td>';
  607. if (! $i) $totalarray['nbfield']++;
  608. }
  609. // Label
  610. if (! empty($arrayfields['t.label']['checked']))
  611. {
  612. print '<td>';
  613. print $object->label;
  614. print '</td>';
  615. if (! $i) $totalarray['nbfield']++;
  616. }
  617. // Date start
  618. if (! empty($arrayfields['t.dateo']['checked']))
  619. {
  620. print '<td class="center">';
  621. print dol_print_date($db->jdate($obj->date_start),'day');
  622. print '</td>';
  623. if (! $i) $totalarray['nbfield']++;
  624. }
  625. // Date end
  626. if (! empty($arrayfields['t.datee']['checked']))
  627. {
  628. print '<td class="center">';
  629. print dol_print_date($db->jdate($obj->date_end),'day');
  630. print '</td>';
  631. if (! $i) $totalarray['nbfield']++;
  632. }
  633. // Project ref
  634. if (! empty($arrayfields['p.ref']['checked']))
  635. {
  636. print '<td class="nowrap">';
  637. print $projectstatic->getNomUrl(1, 'task');
  638. if ($projectstatic->hasDelay()) print img_warning("Late");
  639. print '</td>';
  640. if (! $i) $totalarray['nbfield']++;
  641. }
  642. // Project title
  643. if (! empty($arrayfields['p.title']['checked']))
  644. {
  645. print '<td>';
  646. print dol_trunc($obj->projecttitle,80);
  647. print '</td>';
  648. if (! $i) $totalarray['nbfield']++;
  649. }
  650. // Third party
  651. if (! empty($arrayfields['s.nom']['checked']))
  652. {
  653. print '<td>';
  654. if ($obj->socid)
  655. {
  656. $socstatic->id=$obj->socid;
  657. $socstatic->name=$obj->name;
  658. print $socstatic->getNomUrl(1);
  659. }
  660. else
  661. {
  662. print '&nbsp;';
  663. }
  664. print '</td>';
  665. if (! $i) $totalarray['nbfield']++;
  666. }
  667. // Project status
  668. if (! empty($arrayfields['p.fk_statut']['checked']))
  669. {
  670. print '<td align="center">';
  671. print $projectstatic->getLibStatut(1);
  672. print '</td>';
  673. if (! $i) $totalarray['nbfield']++;
  674. }
  675. // Planned workload
  676. if (! empty($arrayfields['t.planned_workload']['checked']))
  677. {
  678. print '<td class="center">';
  679. $fullhour=convertSecondToTime($obj->planned_workload,$plannedworkloadoutputformat);
  680. $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
  681. if ($obj->planned_workload != '')
  682. {
  683. print $fullhour;
  684. // TODO Add delay taking account of working hours per day and working day per week
  685. //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')';
  686. }
  687. //else print '--:--';
  688. print '</td>';
  689. if (! $i) $totalarray['nbfield']++;
  690. if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield'];
  691. $totalarray['totalplannedworkload'] += $obj->planned_workload;
  692. }
  693. // Time spent
  694. if (! empty($arrayfields['t.duration_effective']['checked']))
  695. {
  696. $showlineingray=0;$showproject=1;
  697. print '<td class="center">';
  698. if ($showlineingray) print '<i>';
  699. else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
  700. if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat);
  701. else print '--:--';
  702. if ($showlineingray) print '</i>';
  703. else print '</a>';
  704. print '</td>';
  705. if (! $i) $totalarray['nbfield']++;
  706. if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield'];
  707. $totalarray['totaldurationeffective'] += $obj->duration_effective;
  708. }
  709. // Calculated progress
  710. if (! empty($arrayfields['t.progress_calculated']['checked']))
  711. {
  712. print '<td class="center">';
  713. if ($obj->planned_workload || $obj->duration_effective)
  714. {
  715. if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload,2).' %';
  716. else print $form->textwithpicto('',$langs->trans('WorkloadNotDefined'), 1, 'help');
  717. }
  718. print '</td>';
  719. if (! $i) $totalarray['nbfield']++;
  720. if (! $i) $totalarray['totalprogress_calculated']=$totalarray['nbfield'];
  721. }
  722. // Declared progress
  723. if (! empty($arrayfields['t.progress']['checked']))
  724. {
  725. print '<td class="center">';
  726. if ($obj->progress != '')
  727. {
  728. print $obj->progress.' %';
  729. }
  730. print '</td>';
  731. if (! $i) $totalarray['nbfield']++;
  732. }
  733. // Extra fields
  734. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  735. {
  736. foreach($extrafields->attribute_label as $key => $val)
  737. {
  738. if (! empty($arrayfields["ef.".$key]['checked']))
  739. {
  740. print '<td';
  741. $align=$extrafields->getAlignFlag($key);
  742. if ($align) print ' align="'.$align.'"';
  743. print '>';
  744. $tmpkey='options_'.$key;
  745. print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
  746. print '</td>';
  747. if (! $i) $totalarray['nbfield']++;
  748. }
  749. }
  750. }
  751. // Fields from hook
  752. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  753. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  754. print $hookmanager->resPrint;
  755. // Date creation
  756. if (! empty($arrayfields['t.datec']['checked']))
  757. {
  758. print '<td align="center">';
  759. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  760. print '</td>';
  761. if (! $i) $totalarray['nbfield']++;
  762. }
  763. // Date modification
  764. if (! empty($arrayfields['t.tms']['checked']))
  765. {
  766. print '<td align="center">';
  767. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  768. print '</td>';
  769. if (! $i) $totalarray['nbfield']++;
  770. }
  771. // Status
  772. /*if (! empty($arrayfields['p.fk_statut']['checked']))
  773. {
  774. $projectstatic->statut = $obj->fk_statut;
  775. print '<td align="right">'.$projectstatic->getLibStatut(5).'</td>';
  776. }*/
  777. // Action column
  778. print '<td class="nowrap" align="center">';
  779. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  780. {
  781. $selected=0;
  782. if (in_array($obj->id, $arrayofselected)) $selected=1;
  783. print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected?' checked="checked"':'').'>';
  784. }
  785. print '</td>';
  786. if (! $i) $totalarray['nbfield']++;
  787. print "</tr>\n";
  788. //print projectLinesa();
  789. }
  790. $i++;
  791. }
  792. // Show total line
  793. if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield']))
  794. {
  795. print '<tr class="liste_total">';
  796. $i=0;
  797. while ($i < $totalarray['nbfield'])
  798. {
  799. $i++;
  800. if ($i == 1)
  801. {
  802. if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
  803. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  804. }
  805. elseif ($totalarray['totalplannedworkloadfield'] == $i) print '<td align="center">'.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).'</td>';
  806. elseif ($totalarray['totaldurationeffectivefield'] == $i) print '<td align="center">'.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).'</td>';
  807. elseif ($totalarray['totalprogress_calculated'] == $i) print '<td align="center">'.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').'</td>';
  808. else print '<td></td>';
  809. }
  810. print '</tr>';
  811. }
  812. $db->free($resql);
  813. $parameters=array('sql' => $sql);
  814. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  815. print $hookmanager->resPrint;
  816. print "</table>";
  817. print '</div>';
  818. print '</form>';
  819. llxFooter();
  820. $db->close();