list.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Bariley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  7. * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/projet/list.php
  24. * \ingroup projet
  25. * \brief Page to list projects
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  32. $langs->loadLangs(array('projects', 'companies', 'commercial'));
  33. $action=GETPOST('action','alpha');
  34. $massaction=GETPOST('massaction','alpha');
  35. $show_files=GETPOST('show_files','int');
  36. $confirm=GETPOST('confirm','alpha');
  37. $toselect = GETPOST('toselect', 'array');
  38. $title = $langs->trans("Projects");
  39. // Security check
  40. $socid = (is_numeric($_GET["socid"]) ? $_GET["socid"] : 0 );
  41. //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.
  42. if ($socid > 0)
  43. {
  44. $soc = new Societe($db);
  45. $soc->fetch($socid);
  46. $title .= ' (<a href="list.php">'.$soc->name.'</a>)';
  47. }
  48. if (!$user->rights->projet->lire) accessforbidden();
  49. $diroutputmassaction=$conf->projet->dir_output . '/temp/massgeneration/'.$user->id;
  50. $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
  51. $sortfield = GETPOST("sortfield","alpha");
  52. $sortorder = GETPOST("sortorder");
  53. $page = GETPOST("page");
  54. $page = is_numeric($page) ? $page : 0;
  55. $page = $page == -1 ? 0 : $page;
  56. if (! $sortfield) $sortfield="p.ref";
  57. if (! $sortorder) $sortorder="ASC";
  58. $offset = $limit * $page ;
  59. $pageprev = $page - 1;
  60. $pagenext = $page + 1;
  61. $search_all=GETPOST('search_all', 'alphanohtml');
  62. $search_categ=GETPOST("search_categ",'alpha');
  63. $search_ref=GETPOST("search_ref");
  64. $search_label=GETPOST("search_label");
  65. $search_societe=GETPOST("search_societe");
  66. $search_year=GETPOST("search_year");
  67. $search_status=GETPOST("search_status",'int');
  68. $search_opp_status=GETPOST("search_opp_status",'alpha');
  69. $search_opp_percent=GETPOST("search_opp_percent",'alpha');
  70. $search_opp_amount=GETPOST("search_opp_amount",'alpha');
  71. $search_budget_amount=GETPOST("search_budget_amount",'alpha');
  72. $search_public=GETPOST("search_public",'int');
  73. $search_project_user=GETPOST('search_project_user','int');
  74. $search_sale=GETPOST('search_sale','int');
  75. $optioncss = GETPOST('optioncss','alpha');
  76. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  77. if ($mine) { $search_project_user = $user->id; $mine=0; }
  78. $search_sday = GETPOST('search_sday','int');
  79. $search_smonth = GETPOST('search_smonth','int');
  80. $search_syear = GETPOST('search_syear','int');
  81. $search_eday = GETPOST('search_eday','int');
  82. $search_emonth = GETPOST('search_emonth','int');
  83. $search_eyear = GETPOST('search_eyear','int');
  84. if ($search_status == '') $search_status=-1; // -1 or 1
  85. // Initialize context for list
  86. $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'projectlist';
  87. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  88. $hookmanager->initHooks(array($contextpage));
  89. $extrafields = new ExtraFields($db);
  90. // fetch optionals attributes and labels
  91. $extralabels = $extrafields->fetch_name_optionals_label('projet');
  92. $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
  93. // List of fields to search into when doing a "search in all"
  94. $fieldstosearchall = array(
  95. 'p.ref'=>"Ref",
  96. 'p.title'=>"Label",
  97. 's.nom'=>"ThirdPartyName",
  98. "p.note_public"=>"NotePublic"
  99. );
  100. if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate";
  101. $arrayfields=array(
  102. 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  103. 'p.title'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
  104. 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>$conf->societe->enabled),
  105. 'commercial'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>1),
  106. 'p.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100),
  107. 'p.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101),
  108. 'p.public'=>array('label'=>$langs->trans("Visibility"), 'checked'=>1, 'position'=>102),
  109. 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103),
  110. 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104),
  111. 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105),
  112. 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110),
  113. 'p.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500),
  114. 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  115. 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  116. );
  117. // Extra fields
  118. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  119. {
  120. foreach($extrafields->attribute_label as $key => $val)
  121. {
  122. $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
  123. }
  124. }
  125. $object = new Project($db);
  126. /*
  127. * Actions
  128. */
  129. if (GETPOST('cancel')) { $action='list'; $massaction=''; }
  130. if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
  131. $parameters=array('socid'=>$socid);
  132. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  133. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  134. if (empty($reshook))
  135. {
  136. // Selection of new fields
  137. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  138. // Purge search criteria
  139. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
  140. {
  141. $search_all='';
  142. $search_categ='';
  143. $search_ref="";
  144. $search_label="";
  145. $search_societe="";
  146. $search_year="";
  147. $search_status=-1;
  148. $search_opp_status=-1;
  149. $search_opp_amount='';
  150. $search_opp_percent='';
  151. $search_budget_amount='';
  152. $search_public="";
  153. $search_sale="";
  154. $search_project_user='';
  155. $search_sday="";
  156. $search_smonth="";
  157. $search_syear="";
  158. $search_eday="";
  159. $search_emonth="";
  160. $search_eyear="";
  161. $toselect='';
  162. $search_array_options=array();
  163. }
  164. // Mass actions
  165. $objectclass='Project';
  166. $objectlabel='Project';
  167. $permtoread = $user->rights->projet->lire;
  168. $permtodelete = $user->rights->projet->supprimer;
  169. $uploaddir = $conf->projet->dir_output;
  170. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  171. }
  172. /*
  173. * View
  174. */
  175. $socstatic = new Societe($db);
  176. $form = new Form($db);
  177. $formother = new FormOther($db);
  178. $formproject = new FormProjets($db);
  179. $title=$langs->trans("Projects");
  180. //if ($search_project_user == $user->id) $title=$langs->trans("MyProjects");
  181. // Get list of project id allowed to user (in a string list separated by coma)
  182. $projectsListId='';
  183. if (! $user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user,0,1,$socid);
  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 = '" . $object->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. $distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
  200. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat";
  201. $sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
  202. $sql.= ", s.nom as name, s.rowid as socid";
  203. $sql.= ", cls.code as opp_status_code";
  204. // We'll need these fields in order to filter by categ
  205. if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project";
  206. // Add fields for extrafields
  207. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  208. // Add fields from hooks
  209. $parameters=array();
  210. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  211. $sql.=$hookmanager->resPrint;
  212. $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
  213. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as ef on (p.rowid = ef.fk_object)";
  214. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
  215. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
  216. // We'll need this table joined to the select in order to filter by categ
  217. 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
  218. // We'll need this table joined to the select in order to filter by sale
  219. // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
  220. //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
  221. if ($search_sale > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
  222. if ($search_project_user > 0)
  223. {
  224. $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp";
  225. }
  226. $sql.= " WHERE p.entity IN (".getEntity('project',1).')';
  227. if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
  228. // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
  229. if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
  230. if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
  231. if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
  232. if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
  233. if ($search_label) $sql .= natural_search('p.title', $search_label);
  234. if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
  235. if ($search_opp_amount) $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
  236. if ($search_opp_percent) $sql .= natural_search('p.opp_percent', $search_opp_percent, 1);
  237. if ($search_smonth > 0)
  238. {
  239. if ($search_syear > 0 && empty($search_sday))
  240. $sql.= " AND p.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))."'";
  241. else if ($search_syear > 0 && ! empty($search_sday))
  242. $sql.= " AND p.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))."'";
  243. else
  244. $sql.= " AND date_format(p.dateo, '%m') = '".$search_smonth."'";
  245. }
  246. else if ($search_syear > 0)
  247. {
  248. $sql.= " AND p.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,1,false))."' AND '".$db->idate(dol_get_last_day($search_syear,12,false))."'";
  249. }
  250. if ($search_emonth > 0)
  251. {
  252. if ($search_eyear > 0 && empty($search_eday))
  253. $sql.= " AND p.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))."'";
  254. else if ($search_eyear > 0 && ! empty($search_eday))
  255. $sql.= " AND p.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))."'";
  256. else
  257. $sql.= " AND date_format(p.datee, '%m') = '".$search_emonth."'";
  258. }
  259. else if ($search_eyear > 0)
  260. {
  261. $sql.= " AND p.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,12,false))."'";
  262. }
  263. if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  264. if ($search_status >= 0)
  265. {
  266. if ($search_status == 99) $sql .= " AND p.fk_statut <> 2";
  267. else $sql .= " AND p.fk_statut = ".$db->escape($search_status);
  268. }
  269. if ($search_opp_status)
  270. {
  271. if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status);
  272. if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL";
  273. if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))";
  274. if ($search_opp_status == 'none') $sql .= " AND p.fk_opp_status IS NULL";
  275. }
  276. if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public);
  277. if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale;
  278. // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
  279. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
  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_opp_amount != '') $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
  282. if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $search_budget_amount, 1);
  283. // Add where from extra fields
  284. foreach ($search_array_options as $key => $val)
  285. {
  286. $crit=$val;
  287. $tmpkey=preg_replace('/search_options_/','',$key);
  288. $typ=$extrafields->attribute_type[$tmpkey];
  289. $mode=0;
  290. if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
  291. if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
  292. {
  293. $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
  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. header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
  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_ref != '') $param.='&search_ref='.$search_ref;
  339. if ($search_label != '') $param.='&search_label='.$search_label;
  340. if ($search_societe != '') $param.='&search_societe='.$search_societe;
  341. if ($search_status >= 0) $param.='&search_status='.$search_status;
  342. if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status);
  343. if ((is_numeric($search_opp_percent) && $search_opp_percent >= 0) || in_array($search_opp_percent, array('all','openedopp','none'))) $param.='&search_opp_percent='.urlencode($search_opp_percent);
  344. if ($search_public != '') $param.='&search_public='.$search_public;
  345. if ($search_project_user != '') $param.='&search_project_user='.$search_project_user;
  346. if ($search_sale > 0) $param.='&search_sale='.$search_sale;
  347. if ($search_opp_amount != '') $param.='&search_opp_amount='.$search_opp_amount;
  348. if ($search_budget_amount != '') $param.='&search_budget_amount='.$search_budget_amount;
  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['delete']=$langs->trans("Delete");
  364. if ($massaction == 'presend') $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="formfilteraction" id="formfilteraction" value="list">';
  370. print '<input type="hidden" name="action" 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"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit);
  377. // Show description of content
  378. if ($search_project_user == $user->id) print $langs->trans("MyProjectsDesc").'<br><br>';
  379. else
  380. {
  381. if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'<br><br>';
  382. else print $langs->trans("ProjectsPublicDesc").'<br><br>';
  383. }
  384. if ($search_all)
  385. {
  386. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  387. print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
  388. }
  389. $moreforfilter='';
  390. // Filter on categories
  391. if (! empty($conf->categorie->enabled))
  392. {
  393. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  394. $moreforfilter.='<div class="divsearchfield">';
  395. $moreforfilter.=$langs->trans('ProjectCategories'). ': ';
  396. $moreforfilter.=$formother->select_categories('project',$search_categ,'search_categ',1);
  397. $moreforfilter.='</div>';
  398. }
  399. // If the user can view user other than himself
  400. $moreforfilter.='<div class="divsearchfield">';
  401. $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': ';
  402. $includeonly='';
  403. if (empty($user->rights->user->user->lire)) $includeonly=array($user->id);
  404. $moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300');
  405. $moreforfilter.='</div>';
  406. // If the user can view thirdparties other than his'
  407. if ($user->rights->societe->client->voir || $socid)
  408. {
  409. $langs->load("commercial");
  410. $moreforfilter.='<div class="divsearchfield">';
  411. $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
  412. $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300');
  413. $moreforfilter.='</div>';
  414. }
  415. if (! empty($moreforfilter))
  416. {
  417. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  418. print $moreforfilter;
  419. $parameters=array();
  420. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  421. print $hookmanager->resPrint;
  422. print '</div>';
  423. }
  424. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  425. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  426. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  427. print '<div class="div-table-responsive">';
  428. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  429. print '<tr class="liste_titre_filter">';
  430. if (! empty($arrayfields['p.ref']['checked']))
  431. {
  432. print '<td class="liste_titre">';
  433. print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="6">';
  434. print '</td>';
  435. }
  436. if (! empty($arrayfields['p.title']['checked']))
  437. {
  438. print '<td class="liste_titre">';
  439. print '<input type="text" class="flat" name="search_label" size="8" value="'.$search_label.'">';
  440. print '</td>';
  441. }
  442. if (! empty($arrayfields['s.nom']['checked']))
  443. {
  444. print '<td class="liste_titre">';
  445. print '<input type="text" class="flat" name="search_societe" size="8" value="'.$search_societe.'">';
  446. print '</td>';
  447. }
  448. // Sale representative
  449. if (! empty($arrayfields['commercial']['checked']))
  450. {
  451. print '<td class="liste_titre">&nbsp;</td>';
  452. }
  453. // Start date
  454. if (! empty($arrayfields['p.dateo']['checked']))
  455. {
  456. print '<td class="liste_titre center">';
  457. 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.'">';
  458. print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.$search_smonth.'">';
  459. $formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5);
  460. print '</td>';
  461. }
  462. // End date
  463. if (! empty($arrayfields['p.datee']['checked']))
  464. {
  465. print '<td class="liste_titre center">';
  466. 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.'">';
  467. print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.$search_emonth.'">';
  468. $formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5);
  469. print '</td>';
  470. }
  471. if (! empty($arrayfields['p.public']['checked']))
  472. {
  473. print '<td class="liste_titre">';
  474. $array=array(''=>'',0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
  475. print $form->selectarray('search_public',$array,$search_public);
  476. print '</td>';
  477. }
  478. if (! empty($arrayfields['p.opp_amount']['checked']))
  479. {
  480. print '<td class="liste_titre nowrap right">';
  481. print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
  482. print '</td>';
  483. }
  484. if (! empty($arrayfields['p.fk_opp_status']['checked']))
  485. {
  486. print '<td class="liste_titre nowrap center">';
  487. print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth100');
  488. print '</td>';
  489. }
  490. if (! empty($arrayfields['p.opp_percent']['checked']))
  491. {
  492. print '<td class="liste_titre nowrap right">';
  493. print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
  494. print '</td>';
  495. }
  496. if (! empty($arrayfields['p.budget_amount']['checked']))
  497. {
  498. print '<td class="liste_titre nowrap" align="right">';
  499. print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
  500. print '</td>';
  501. }
  502. // Extra fields
  503. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  504. {
  505. foreach($extrafields->attribute_label as $key => $val)
  506. {
  507. if (! empty($arrayfields["ef.".$key]['checked']))
  508. {
  509. $align=$extrafields->getAlignFlag($key);
  510. $typeofextrafield=$extrafields->attribute_type[$key];
  511. print '<td class="liste_titre'.($align?' '.$align:'').'">';
  512. if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
  513. {
  514. $crit=$val;
  515. $tmpkey=preg_replace('/search_options_/','',$key);
  516. $searchclass='';
  517. if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
  518. if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
  519. print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
  520. }
  521. print '</td>';
  522. }
  523. }
  524. }
  525. // Fields from hook
  526. $parameters=array('arrayfields'=>$arrayfields);
  527. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  528. print $hookmanager->resPrint;
  529. if (! empty($arrayfields['p.datec']['checked']))
  530. {
  531. // Date creation
  532. print '<td class="liste_titre">';
  533. print '</td>';
  534. }
  535. if (! empty($arrayfields['p.tms']['checked']))
  536. {
  537. // Date modification
  538. print '<td class="liste_titre">';
  539. print '</td>';
  540. }
  541. if (! empty($arrayfields['p.fk_statut']['checked']))
  542. {
  543. print '<td class="liste_titre nowrap" align="right">';
  544. $arrayofstatus = array();
  545. foreach($object->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val);
  546. $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')';
  547. print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
  548. print '</td>';
  549. }
  550. // Action column
  551. print '<td class="liste_titre" align="right">';
  552. $searchpicto=$form->showFilterButtons();
  553. print $searchpicto;
  554. print '</td>';
  555. print '</tr>'."\n";
  556. print '<tr class="liste_titre">';
  557. if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder);
  558. if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder);
  559. if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
  560. if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'],$_SERVER["PHP_SELF"],"","",$param,"",$sortfield,$sortorder);
  561. if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'],$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder);
  562. if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'],$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder);
  563. if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'],$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder);
  564. if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'],$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder);
  565. if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'],$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'align="center"',$sortfield,$sortorder);
  566. if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'],$_SERVER["PHP_SELF"],'p.opp_percent',"",$param,'align="right"',$sortfield,$sortorder);
  567. if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'],$_SERVER["PHP_SELF"],'p.budget_amount',"",$param,'align="right"',$sortfield,$sortorder);
  568. // Extra fields
  569. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  570. {
  571. foreach($extrafields->attribute_label as $key => $val)
  572. {
  573. if (! empty($arrayfields["ef.".$key]['checked']))
  574. {
  575. $align=$extrafields->getAlignFlag($key);
  576. $sortonfield = "ef.".$key;
  577. if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
  578. print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
  579. }
  580. }
  581. }
  582. // Hook fields
  583. $parameters=array('arrayfields'=>$arrayfields);
  584. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  585. print $hookmanager->resPrint;
  586. if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  587. if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  588. if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
  589. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  590. print "</tr>\n";
  591. $i=0;
  592. $totalarray=array();
  593. while ($i < min($num,$limit))
  594. {
  595. $obj = $db->fetch_object($resql);
  596. $object->id = $obj->id;
  597. $object->user_author_id = $obj->fk_user_creat;
  598. $object->public = $obj->public;
  599. $object->ref = $obj->ref;
  600. $object->datee = $db->jdate($obj->date_end);
  601. $object->statut = $obj->fk_statut;
  602. $object->opp_status = $obj->fk_opp_status;
  603. $userAccess = $object->restrictedProjectArea($user); // why this ?
  604. if ($userAccess >= 0)
  605. {
  606. print '<tr class="oddeven">';
  607. // Project url
  608. if (! empty($arrayfields['p.ref']['checked']))
  609. {
  610. print '<td class="nowrap">';
  611. print $object->getNomUrl(1);
  612. if ($object->hasDelay()) print img_warning($langs->trans('Late'));
  613. print '</td>';
  614. if (! $i) $totalarray['nbfield']++;
  615. }
  616. // Title
  617. if (! empty($arrayfields['p.title']['checked']))
  618. {
  619. print '<td class="tdoverflowmax100">';
  620. print dol_trunc($obj->title,80);
  621. print '</td>';
  622. if (! $i) $totalarray['nbfield']++;
  623. }
  624. // Company
  625. if (! empty($arrayfields['s.nom']['checked']))
  626. {
  627. print '<td class="tdoverflowmax100">';
  628. if ($obj->socid)
  629. {
  630. $socstatic->id=$obj->socid;
  631. $socstatic->name=$obj->name;
  632. print $socstatic->getNomUrl(1);
  633. }
  634. else
  635. {
  636. print '&nbsp;';
  637. }
  638. print '</td>';
  639. if (! $i) $totalarray['nbfield']++;
  640. }
  641. // Sales Representatives
  642. if (! empty($arrayfields['commercial']['checked']))
  643. {
  644. print '<td>';
  645. if ($obj->socid)
  646. {
  647. $socstatic->id=$obj->socid;
  648. $socstatic->name=$obj->name;
  649. $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user);
  650. $nbofsalesrepresentative=count($listsalesrepresentatives);
  651. if ($nbofsalesrepresentative > 3) // We print only number
  652. {
  653. print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$socstatic->id.'">';
  654. print $nbofsalesrepresentative;
  655. print '</a>';
  656. }
  657. else if ($nbofsalesrepresentative > 0)
  658. {
  659. $userstatic=new User($db);
  660. $j=0;
  661. foreach($listsalesrepresentatives as $val)
  662. {
  663. $userstatic->id=$val['id'];
  664. $userstatic->lastname=$val['lastname'];
  665. $userstatic->firstname=$val['firstname'];
  666. $userstatic->email=$val['email'];
  667. $userstatic->statut=$val['statut'];
  668. $userstatic->entity=$val['entity'];
  669. $userstatic->photo=$val['photo'];
  670. //print $userstatic->getNomUrl(1, '', 0, 0, 12);
  671. print $userstatic->getNomUrl(-2);
  672. $j++;
  673. if ($j < $nbofsalesrepresentative) print ' ';
  674. }
  675. }
  676. //else print $langs->trans("NoSalesRepresentativeAffected");
  677. }
  678. else
  679. {
  680. print '&nbsp';
  681. }
  682. print '</td>';
  683. if (! $i) $totalarray['nbfield']++;
  684. }
  685. // Date start
  686. if (! empty($arrayfields['p.dateo']['checked']))
  687. {
  688. print '<td class="center">';
  689. print dol_print_date($db->jdate($obj->date_start),'day');
  690. print '</td>';
  691. if (! $i) $totalarray['nbfield']++;
  692. }
  693. // Date end
  694. if (! empty($arrayfields['p.datee']['checked']))
  695. {
  696. print '<td class="center">';
  697. print dol_print_date($db->jdate($obj->date_end),'day');
  698. print '</td>';
  699. if (! $i) $totalarray['nbfield']++;
  700. }
  701. // Visibility
  702. if (! empty($arrayfields['p.public']['checked']))
  703. {
  704. print '<td align="left">';
  705. if ($obj->public) print $langs->trans('SharedProject');
  706. else print $langs->trans('PrivateProject');
  707. print '</td>';
  708. if (! $i) $totalarray['nbfield']++;
  709. }
  710. // Opp Amount
  711. if (! empty($arrayfields['p.opp_amount']['checked']))
  712. {
  713. print '<td align="right">';
  714. if ($obj->opp_status_code)
  715. {
  716. print price($obj->opp_amount, 1, '', 1, -1, -1, '');
  717. $totalarray['totalopp'] += $obj->opp_amount;
  718. }
  719. print '</td>';
  720. if (! $i) $totalarray['nbfield']++;
  721. if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield'];
  722. }
  723. // Opp Status
  724. if (! empty($arrayfields['p.fk_opp_status']['checked']))
  725. {
  726. print '<td class="center">';
  727. if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code);
  728. print '</td>';
  729. if (! $i) $totalarray['nbfield']++;
  730. }
  731. // Opp percent
  732. if (! empty($arrayfields['p.opp_percent']['checked']))
  733. {
  734. print '<td align="right">';
  735. if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%';
  736. print '</td>';
  737. if (! $i) $totalarray['nbfield']++;
  738. }
  739. // Budget
  740. if (! empty($arrayfields['p.budget_amount']['checked']))
  741. {
  742. print '<td align="right">';
  743. if ($obj->budget_amount != '')
  744. {
  745. print price($obj->budget_amount, 1, '', 1, -1, -1);
  746. $totalarray['totalbudget'] += $obj->budget_amount;
  747. }
  748. print '</td>';
  749. if (! $i) $totalarray['nbfield']++;
  750. if (! $i) $totalarray['totalbudgetfield']=$totalarray['nbfield'];
  751. }
  752. // Extra fields
  753. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  754. {
  755. foreach($extrafields->attribute_label as $key => $val)
  756. {
  757. if (! empty($arrayfields["ef.".$key]['checked']))
  758. {
  759. print '<td';
  760. $align=$extrafields->getAlignFlag($key);
  761. if ($align) print ' align="'.$align.'"';
  762. print '>';
  763. $tmpkey='options_'.$key;
  764. print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
  765. print '</td>';
  766. }
  767. }
  768. if (! $i) $totalarray['nbfield']++;
  769. }
  770. // Fields from hook
  771. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  772. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  773. print $hookmanager->resPrint;
  774. // Date creation
  775. if (! empty($arrayfields['p.datec']['checked']))
  776. {
  777. print '<td align="center">';
  778. print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
  779. print '</td>';
  780. if (! $i) $totalarray['nbfield']++;
  781. }
  782. // Date modification
  783. if (! empty($arrayfields['p.tms']['checked']))
  784. {
  785. print '<td align="center">';
  786. print dol_print_date($db->jdate($obj->date_update), 'dayhour');
  787. print '</td>';
  788. if (! $i) $totalarray['nbfield']++;
  789. }
  790. // Status
  791. if (! empty($arrayfields['p.fk_statut']['checked']))
  792. {
  793. print '<td align="right">'.$object->getLibStatut(5).'</td>';
  794. if (! $i) $totalarray['nbfield']++;
  795. }
  796. // Action column
  797. print '<td class="nowrap" align="center">';
  798. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  799. {
  800. $selected=0;
  801. if (in_array($obj->id, $arrayofselected)) $selected=1;
  802. print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected?' checked="checked"':'').'>';
  803. }
  804. print '</td>';
  805. if (! $i) $totalarray['nbfield']++;
  806. print "</tr>\n";
  807. }
  808. $i++;
  809. }
  810. // Show total line
  811. if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield']))
  812. {
  813. print '<tr class="liste_total">';
  814. $i=0;
  815. while ($i < $totalarray['nbfield'])
  816. {
  817. $i++;
  818. if ($i == 1)
  819. {
  820. if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
  821. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  822. }
  823. elseif ($totalarray['totaloppfield'] == $i) print '<td align="right">'.price($totalarray['totalopp']).'</td>';
  824. elseif ($totalarray['totalbudgetfield'] == $i) print '<td align="right">'.price($totalarray['totalbudget']).'</td>';
  825. else print '<td></td>';
  826. }
  827. print '</tr>';
  828. }
  829. $db->free($resql);
  830. $parameters=array('sql' => $sql);
  831. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  832. print $hookmanager->resPrint;
  833. print "</table>\n";
  834. print '</div>';
  835. print "</form>\n";
  836. llxFooter();
  837. $db->close();