list.php 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. <?php
  2. /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  7. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  8. * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
  9. * Copyright (C) 2021-2023 Frédéric France <frederic.france@netlogic.fr>
  10. * Copyright (C) 2022 Charlène Benke <charlene@patas-monkey.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/fichinter/list.php
  27. * \brief List of all interventions
  28. * \ingroup ficheinter
  29. */
  30. // Load Dolibarr environment
  31. require '../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  36. if (isModEnabled('project')) {
  37. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  38. }
  39. if (isModEnabled('contrat')) {
  40. require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  41. }
  42. // Load translation files required by the page
  43. $langs->loadLangs(array('companies', 'bills', 'interventions'));
  44. if (isModEnabled('project')) {
  45. $langs->load("projects");
  46. }
  47. if (isModEnabled('contrat')) {
  48. $langs->load("contracts");
  49. }
  50. $action = GETPOST('action', 'aZ09');
  51. $massaction = GETPOST('massaction', 'alpha');
  52. $show_files = GETPOST('show_files', 'int');
  53. $confirm = GETPOST('confirm', 'alpha');
  54. $toselect = GETPOST('toselect', 'array');
  55. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'interventionlist';
  56. $mode = GETPOST('mode', 'alpha');
  57. $search_ref = GETPOST('search_ref') ?GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha');
  58. $search_ref_client = GETPOST('search_ref_client', 'alpha');
  59. $search_company = GETPOST('search_company', 'alpha');
  60. $search_desc = GETPOST('search_desc', 'alpha');
  61. $search_projet_ref = GETPOST('search_projet_ref', 'alpha');
  62. $search_contrat_ref = GETPOST('search_contrat_ref', 'alpha');
  63. $search_status = GETPOST('search_status', 'alpha');
  64. $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  65. $optioncss = GETPOST('optioncss', 'alpha');
  66. $socid = GETPOST('socid', 'int');
  67. $diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id;
  68. // Load variable for pagination
  69. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  70. $sortfield = GETPOST('sortfield', 'aZ09comma');
  71. $sortorder = GETPOST('sortorder', 'aZ09comma');
  72. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  73. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  74. // If $page is not defined, or '' or -1 or if we click on clear filters
  75. $page = 0;
  76. }
  77. $offset = $limit * $page;
  78. $pageprev = $page - 1;
  79. $pagenext = $page + 1;
  80. if (!$sortorder) {
  81. $sortorder = "DESC";
  82. }
  83. if (!$sortfield) {
  84. $sortfield = "f.ref";
  85. }
  86. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  87. $object = new Fichinter($db);
  88. $hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
  89. $extrafields = new ExtraFields($db);
  90. // Fetch optionals attributes and labels
  91. $extrafields->fetch_name_optionals_label($object->table_element);
  92. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  93. // List of fields to search into when doing a "search in all"
  94. $fieldstosearchall = array(
  95. 'f.ref'=>'Ref',
  96. 's.nom'=>"ThirdParty",
  97. 'f.description'=>'Description',
  98. 'f.note_public'=>'NotePublic',
  99. 'fd.description'=>'DescriptionOfLine',
  100. );
  101. if (empty($user->socid)) {
  102. $fieldstosearchall["f.note_private"] = "NotePrivate";
  103. }
  104. if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
  105. unset($fieldstosearchall['fd.description']);
  106. }
  107. // Definition of fields for list
  108. $arrayfields = array(
  109. 'f.ref'=>array('label'=>'Ref', 'checked'=>1),
  110. 'f.ref_client'=>array('label'=>'RefCustomer', 'checked'=>1),
  111. 's.nom'=>array('label'=>'ThirdParty', 'checked'=>1),
  112. 'pr.ref'=>array('label'=>'Project', 'checked'=>1, 'enabled'=>(!isModEnabled('project') ? 0 : 1)),
  113. 'c.ref'=>array('label'=>'Contract', 'checked'=>1, 'enabled'=>(empty($conf->contrat->enabled) ? 0 : 1)),
  114. 'f.description'=>array('label'=>'Description', 'checked'=>1),
  115. 'f.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>500),
  116. 'f.tms'=>array('label'=>'DateModificationShort', 'checked'=>0, 'position'=>500),
  117. 'f.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))),
  118. 'f.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))),
  119. 'f.fk_statut'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000),
  120. 'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
  121. 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
  122. 'fd.duree'=>array('label'=>'DurationOfLine', 'type'=> 'duration', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), //type duration is here because in database, column 'duree' is double
  123. );
  124. // Extra fields
  125. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  126. $object->fields = dol_sort_array($object->fields, 'position');
  127. $arrayfields = dol_sort_array($arrayfields, 'position');
  128. // Security check
  129. $id = GETPOST('id', 'int');
  130. if ($user->socid) {
  131. $socid = $user->socid;
  132. }
  133. $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
  134. $permissiontoread = $user->rights->ficheinter->lire;
  135. $permissiontoadd = $user->rights->ficheinter->creer;
  136. $permissiontodelete = $user->rights->ficheinter->supprimer;
  137. /*
  138. * Actions
  139. */
  140. if (GETPOST('cancel', 'alpha')) {
  141. $action = 'list';
  142. $massaction = '';
  143. }
  144. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  145. $massaction = '';
  146. }
  147. $parameters = array('socid'=>$socid);
  148. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  149. if ($reshook < 0) {
  150. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  151. }
  152. if (empty($reshook)) {
  153. // Selection of new fields
  154. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  155. // Purge search criteria
  156. 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
  157. $search_ref = "";
  158. $search_ref_client = "";
  159. $search_company = "";
  160. $search_projet_ref = "";
  161. $search_contrat_ref = "";
  162. $search_desc = "";
  163. $search_status = "";
  164. $toselect = array();
  165. $search_array_options = array();
  166. }
  167. // Mass actions
  168. $objectclass = 'Fichinter';
  169. $objectlabel = 'Interventions';
  170. $uploaddir = $conf->ficheinter->dir_output;
  171. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  172. }
  173. /*
  174. * View
  175. */
  176. $form = new Form($db);
  177. $formfile = new FormFile($db);
  178. $objectstatic = new Fichinter($db);
  179. $companystatic = new Societe($db);
  180. if (isModEnabled('project')) {
  181. $projetstatic = new Project($db);
  182. }
  183. if (isModEnabled('contrat')) {
  184. $contratstatic = new Contrat($db);
  185. }
  186. $now = dol_now();
  187. $title = $langs->trans("Interventions");
  188. $help_url = '';
  189. $morejs = array();
  190. $morecss = array();
  191. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  192. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  193. $atleastonefieldinlines = 0;
  194. foreach ($arrayfields as $tmpkey => $tmpval) {
  195. if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) {
  196. $atleastonefieldinlines++;
  197. break;
  198. }
  199. }
  200. $sql = "SELECT";
  201. $sql .= " f.ref, f.ref_client, f.rowid, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private,";
  202. if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
  203. $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
  204. }
  205. $sql .= " s.nom as name, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus";
  206. if (isModEnabled('project')) {
  207. $sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title";
  208. }
  209. if (isModEnabled('contrat')) {
  210. $sql .= ", c.rowid as contrat_id, c.ref as contrat_ref, c.ref_customer as contrat_ref_customer, c.ref_supplier as contrat_ref_supplier";
  211. }
  212. // Add fields from extrafields
  213. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  214. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  215. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  216. }
  217. }
  218. // Add fields from hooks
  219. $parameters = array();
  220. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  221. $sql .= $hookmanager->resPrint;
  222. $sqlfields = $sql; // $sql fields to remove for count total
  223. $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
  224. if (isModEnabled('project')) {
  225. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid";
  226. }
  227. if (isModEnabled('contrat')) {
  228. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid";
  229. }
  230. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  231. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
  232. }
  233. if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
  234. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
  235. }
  236. // Add table from hooks
  237. $parameters = array();
  238. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  239. $sql .= $hookmanager->resPrint;
  240. if (empty($user->rights->societe->client->voir) && empty($socid)) {
  241. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  242. }
  243. $sql .= ", ".MAIN_DB_PREFIX."societe as s";
  244. $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
  245. $sql .= " AND f.fk_soc = s.rowid";
  246. if ($search_ref) {
  247. $sql .= natural_search('f.ref', $search_ref);
  248. }
  249. if ($search_ref_client) {
  250. $sql .= natural_search('f.ref_client', $search_ref_client);
  251. }
  252. if ($search_company) {
  253. $sql .= natural_search('s.nom', $search_company);
  254. }
  255. if ($search_projet_ref) {
  256. $sql .= natural_search('pr.ref', $search_projet_ref);
  257. }
  258. if ($search_contrat_ref) {
  259. $sql .= natural_search('c.ref', $search_contrat_ref);
  260. }
  261. if ($search_desc) {
  262. if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
  263. $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
  264. } else {
  265. $sql .= natural_search(array('f.description'), $search_desc);
  266. }
  267. }
  268. if ($search_status != '' && $search_status >= 0) {
  269. $sql .= ' AND f.fk_statut = '.urlencode($search_status);
  270. }
  271. if (empty($user->rights->societe->client->voir) && empty($socid)) {
  272. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  273. }
  274. if ($socid) {
  275. $sql .= " AND s.rowid = ".((int) $socid);
  276. }
  277. if ($search_all) {
  278. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  279. }
  280. // Add where from extra fields
  281. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  282. // Add where from hooks
  283. $parameters = array();
  284. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  285. $sql .= $hookmanager->resPrint;
  286. // Add GroupBy from hooks
  287. $parameters = array('search_all' => $search_all, 'fieldstosearchall' => $fieldstosearchall);
  288. $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
  289. $sql .= $hookmanager->resPrint;
  290. // Count total nb of records
  291. $nbtotalofrecords = '';
  292. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  293. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  294. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  295. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  296. $resql = $db->query($sqlforcount);
  297. if ($resql) {
  298. $objforcount = $db->fetch_object($resql);
  299. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  300. } else {
  301. dol_print_error($db);
  302. }
  303. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
  304. $page = 0;
  305. $offset = 0;
  306. }
  307. $db->free($resql);
  308. }
  309. // Complete request and execute it with limit
  310. $sql .= $db->order($sortfield, $sortorder);
  311. if ($limit) {
  312. $sql .= $db->plimit($limit + 1, $offset);
  313. }
  314. $resql = $db->query($sql);
  315. if (!$resql) {
  316. dol_print_error($db);
  317. exit;
  318. }
  319. $num = $db->num_rows($resql);
  320. // Direct jump if only one record found
  321. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  322. $obj = $db->fetch_object($resql);
  323. $id = $obj->rowid;
  324. header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id);
  325. exit;
  326. }
  327. // Output page
  328. // --------------------------------------------------------------------
  329. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
  330. $arrayofselected = is_array($toselect) ? $toselect : array();
  331. if ($socid > 0) {
  332. $soc = new Societe($db);
  333. $soc->fetch($socid);
  334. if (empty($search_company)) {
  335. $search_company = $soc->name;
  336. }
  337. }
  338. $param = '';
  339. if (!empty($mode)) {
  340. $param .= '&mode='.urlencode($mode);
  341. }
  342. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  343. $param .= '&contextpage='.urlencode($contextpage);
  344. }
  345. if ($limit > 0 && $limit != $conf->liste_limit) {
  346. $param .= '&limit='.((int) $limit);
  347. }
  348. if ($search_all) {
  349. $param .= "&search_all=".urlencode($search_all);
  350. }
  351. if ($socid) {
  352. $param .= "&socid=".urlencode($socid);
  353. }
  354. if ($search_ref) {
  355. $param .= "&search_ref=".urlencode($search_ref);
  356. }
  357. if ($search_ref_client) {
  358. $param .= "&search_ref_client=".urlencode($search_ref_client);
  359. }
  360. if ($search_company) {
  361. $param .= "&search_company=".urlencode($search_company);
  362. }
  363. if ($search_desc) {
  364. $param .= "&search_desc=".urlencode($search_desc);
  365. }
  366. if ($search_status != '' && $search_status > -1) {
  367. $param .= "&search_status=".urlencode($search_status);
  368. }
  369. if ($show_files) {
  370. $param .= '&show_files='.urlencode($show_files);
  371. }
  372. if ($optioncss != '') {
  373. $param .= '&optioncss='.urlencode($optioncss);
  374. }
  375. // Add $param from extra fields
  376. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  377. // Add $param from hooks
  378. $parameters = array();
  379. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  380. $param .= $hookmanager->resPrint;
  381. // List of mass actions available
  382. $arrayofmassactions = array(
  383. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  384. 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  385. //'presend'=>$langs->trans("SendByMail"),
  386. );
  387. if (!empty($permissiontodelete)) {
  388. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  389. }
  390. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  391. $arrayofmassactions = array();
  392. }
  393. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  394. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  395. if ($optioncss != '') {
  396. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  397. }
  398. print '<input type="hidden" name="token" value="'.newToken().'">';
  399. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  400. print '<input type="hidden" name="action" value="list">';
  401. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  402. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  403. print '<input type="hidden" name="page" value="'.$page.'">';
  404. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  405. print '<input type="hidden" name="page_y" value="">';
  406. print '<input type="hidden" name="mode" value="'.$mode.'">';
  407. $newcardbutton = '';
  408. $url = DOL_URL_ROOT.'/fichinter/card.php?action=create';
  409. if (!empty($socid)) {
  410. $url .= '&socid='.$socid;
  411. }
  412. $newcardbutton = '';
  413. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  414. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
  415. $newcardbutton .= dolGetButtonTitleSeparator();
  416. $newcardbutton .= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer);
  417. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  418. $topicmail = "Information";
  419. $modelmail = "intervention";
  420. $objecttmp = new Fichinter($db);
  421. $trackid = 'int'.$object->id;
  422. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  423. if ($search_all) {
  424. $setupstring = '';
  425. foreach ($fieldstosearchall as $key => $val) {
  426. $fieldstosearchall[$key] = $langs->trans($val);
  427. $setupstring .= $key."=".$val.";";
  428. }
  429. print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  430. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
  431. }
  432. $moreforfilter = '';
  433. $parameters = array();
  434. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  435. if (empty($reshook)) {
  436. $moreforfilter .= $hookmanager->resPrint;
  437. } else {
  438. $moreforfilter = $hookmanager->resPrint;
  439. }
  440. if (!empty($moreforfilter)) {
  441. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  442. print $moreforfilter;
  443. $parameters = array();
  444. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  445. print $hookmanager->resPrint;
  446. print '</div>';
  447. }
  448. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  449. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  450. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  451. print '<div class="div-table-responsive">';
  452. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  453. // Fields title search
  454. // --------------------------------------------------------------------
  455. print '<tr class="liste_titre_filter">';
  456. // Action column
  457. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  458. print '<td class="liste_titre center maxwidthsearch">';
  459. $searchpicto = $form->showFilterButtons('left');
  460. print $searchpicto;
  461. print '</td>';
  462. }
  463. if (!empty($arrayfields['f.ref']['checked'])) {
  464. print '<td class="liste_titre">';
  465. print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
  466. print '</td>';
  467. }
  468. if (!empty($arrayfields['f.ref_client']['checked'])) {
  469. print '<td class="liste_titre">';
  470. print '<input type="text" class="flat" name="search_ref_client" value="'.$search_ref_client.'" size="8">';
  471. print '</td>';
  472. }
  473. if (!empty($arrayfields['s.nom']['checked'])) {
  474. print '<td class="liste_titre">';
  475. print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
  476. print '</td>';
  477. }
  478. if (!empty($arrayfields['pr.ref']['checked'])) {
  479. print '<td class="liste_titre">';
  480. print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">';
  481. print '</td>';
  482. }
  483. if (!empty($arrayfields['c.ref']['checked'])) {
  484. print '<td class="liste_titre">';
  485. print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">';
  486. print '</td>';
  487. }
  488. if (!empty($arrayfields['f.description']['checked'])) {
  489. print '<td class="liste_titre">';
  490. print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
  491. print '</td>';
  492. }
  493. // Extra fields
  494. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  495. // Fields from hook
  496. $parameters = array('arrayfields'=>$arrayfields);
  497. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  498. print $hookmanager->resPrint;
  499. if (!empty($arrayfields['f.datec']['checked'])) {
  500. // Date creation
  501. print '<td class="liste_titre">';
  502. print '</td>';
  503. }
  504. if (!empty($arrayfields['f.tms']['checked'])) {
  505. // Date modification
  506. print '<td class="liste_titre">';
  507. print '</td>';
  508. }
  509. if (!empty($arrayfields['f.note_public']['checked'])) {
  510. // Note public
  511. print '<td class="liste_titre">';
  512. print '</td>';
  513. }
  514. if (!empty($arrayfields['f.note_private']['checked'])) {
  515. // Note private
  516. print '<td class="liste_titre">';
  517. print '</td>';
  518. }
  519. // Status
  520. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  521. print '<td class="liste_titre right parentonrightofpage">';
  522. $liststatus = [
  523. $object::STATUS_DRAFT => $langs->transnoentitiesnoconv('Draft'),
  524. $object::STATUS_VALIDATED => $langs->transnoentitiesnoconv('Validated'),
  525. $object::STATUS_BILLED => $langs->transnoentitiesnoconv('StatusInterInvoiced'),
  526. $object::STATUS_CLOSED => $langs->transnoentitiesnoconv('Done'),
  527. ];
  528. if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
  529. unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
  530. }
  531. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage');
  532. print '</td>';
  533. }
  534. // Fields of detail line
  535. if (!empty($arrayfields['fd.description']['checked'])) {
  536. print '<td class="liste_titre">&nbsp;</td>';
  537. }
  538. if (!empty($arrayfields['fd.date']['checked'])) {
  539. print '<td class="liste_titre">&nbsp;</td>';
  540. }
  541. if (!empty($arrayfields['fd.duree']['checked'])) {
  542. print '<td class="liste_titre">&nbsp;</td>';
  543. }
  544. // Action column
  545. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  546. print '<td class="liste_titre center maxwidthsearch">';
  547. $searchpicto = $form->showFilterButtons();
  548. print $searchpicto;
  549. print '</td>';
  550. }
  551. print '</tr>'."\n";
  552. $totalarray = array();
  553. $totalarray['nbfield'] = 0;
  554. // Fields title label
  555. // --------------------------------------------------------------------
  556. print '<tr class="liste_titre">';
  557. // Action column
  558. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  559. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  560. $totalarray['nbfield']++;
  561. }
  562. if (!empty($arrayfields['f.ref']['checked'])) {
  563. print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
  564. $totalarray['nbfield']++;
  565. }
  566. if (!empty($arrayfields['f.ref_client']['checked'])) {
  567. print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], "f.ref_client", "", $param, '', $sortfield, $sortorder);
  568. $totalarray['nbfield']++;
  569. }
  570. if (!empty($arrayfields['s.nom']['checked'])) {
  571. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
  572. $totalarray['nbfield']++;
  573. }
  574. if (!empty($arrayfields['pr.ref']['checked'])) {
  575. print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
  576. $totalarray['nbfield']++;
  577. }
  578. if (!empty($arrayfields['c.ref']['checked'])) {
  579. print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
  580. $totalarray['nbfield']++;
  581. }
  582. if (!empty($arrayfields['f.description']['checked'])) {
  583. print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
  584. $totalarray['nbfield']++;
  585. }
  586. // Extra fields
  587. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  588. // Hook fields
  589. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  590. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  591. print $hookmanager->resPrint;
  592. if (!empty($arrayfields['f.datec']['checked'])) {
  593. print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  594. $totalarray['nbfield']++;
  595. }
  596. if (!empty($arrayfields['f.tms']['checked'])) {
  597. print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  598. $totalarray['nbfield']++;
  599. }
  600. if (!empty($arrayfields['f.note_public']['checked'])) {
  601. print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  602. $totalarray['nbfield']++;
  603. }
  604. if (!empty($arrayfields['f.note_private']['checked'])) {
  605. print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  606. $totalarray['nbfield']++;
  607. }
  608. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  609. print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
  610. $totalarray['nbfield']++;
  611. }
  612. if (!empty($arrayfields['fd.description']['checked'])) {
  613. print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
  614. $totalarray['nbfield']++;
  615. }
  616. if (!empty($arrayfields['fd.date']['checked'])) {
  617. print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
  618. $totalarray['nbfield']++;
  619. }
  620. if (!empty($arrayfields['fd.duree']['checked'])) {
  621. print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
  622. $totalarray['nbfield']++;
  623. }
  624. // Action column
  625. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  626. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  627. $totalarray['nbfield']++;
  628. }
  629. print "</tr>\n";
  630. // Loop on record
  631. // --------------------------------------------------------------------
  632. $i = 0;
  633. $savnbfield = $totalarray['nbfield'];
  634. $totalarray = array();
  635. $totalarray['nbfield'] = 0;
  636. $totalarray['val'] = array();
  637. $totalarray['val']['fd.duree'] = 0;
  638. $total = 0;
  639. $imaxinloop = ($limit ? min($num, $limit) : $num);
  640. while ($i < $imaxinloop) {
  641. $obj = $db->fetch_object($resql);
  642. if (empty($obj)) {
  643. break; // Should not happen
  644. }
  645. // Store properties in $object
  646. //$object->setVarsFromFetchObj($obj);
  647. $objectstatic->id = $obj->rowid;
  648. $objectstatic->ref = $obj->ref;
  649. $objectstatic->ref_client = $obj->ref_client;
  650. $objectstatic->statut = $obj->status;
  651. $objectstatic->status = $obj->status;
  652. $companystatic->name = $obj->name;
  653. $companystatic->id = $obj->socid;
  654. $companystatic->client = $obj->client;
  655. $companystatic->fournisseur = $obj->fournisseur;
  656. $companystatic->email = $obj->email;
  657. $companystatic->status = $obj->thirdpartystatus;
  658. //mode kanban
  659. if ($mode == 'kanban') {
  660. if ($i == 0) {
  661. print '<tr><td colspan="'.$savnbfield.'">';
  662. print '<div class="box-flex-container kanban">';
  663. }
  664. // Output Kanban
  665. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  666. $selected = 0;
  667. if (in_array($object->id, $arrayofselected)) {
  668. $selected = 1;
  669. }
  670. }
  671. $objectstatic->duration = $obj->duree;
  672. $arraydata['thirdparty'] = $companystatic;
  673. print $objectstatic->getKanbanView('', $arraydata);
  674. if ($i == ($imaxinloop - 1)) {
  675. print '</div>';
  676. print '</td></tr>';
  677. }
  678. } else {
  679. // Show here line of result
  680. $j = 0;
  681. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  682. // Action column
  683. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  684. print '<td class="nowrap center">';
  685. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  686. $selected = 0;
  687. if (in_array($obj->rowid, $arrayofselected)) {
  688. $selected = 1;
  689. }
  690. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  691. }
  692. print '</td>';
  693. if (!$i) {
  694. $totalarray['nbfield']++;
  695. }
  696. }
  697. if (!empty($arrayfields['f.ref']['checked'])) {
  698. print "<td>";
  699. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  700. // Picto + Ref
  701. print '<td class="nobordernopadding nowraponall">';
  702. print $objectstatic->getNomUrl(1);
  703. print '</td>';
  704. // Warning
  705. $warnornote = '';
  706. //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
  707. if (!empty($obj->note_private)) {
  708. $warnornote .= ($warnornote ? ' ' : '');
  709. $warnornote .= '<span class="note">';
  710. $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
  711. $warnornote .= '</span>';
  712. }
  713. if ($warnornote) {
  714. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  715. print $warnornote;
  716. print '</td>';
  717. }
  718. // Other picto tool
  719. print '<td width="16" class="right nobordernopadding hideonsmartphone">';
  720. $filename = dol_sanitizeFileName($obj->ref);
  721. $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
  722. $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  723. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  724. print '</td></tr></table>';
  725. print "</td>\n";
  726. if (!$i) {
  727. $totalarray['nbfield']++;
  728. }
  729. }
  730. if (!empty($arrayfields['f.ref_client']['checked'])) {
  731. // Customer ref
  732. print '<td class="nowrap tdoverflowmax200">';
  733. print dol_escape_htmltag($obj->ref_client);
  734. print '</td>';
  735. if (!$i) {
  736. $totalarray['nbfield']++;
  737. }
  738. }
  739. if (!empty($arrayfields['s.nom']['checked'])) {
  740. print '<td>';
  741. print $companystatic->getNomUrl(1, '', 44);
  742. print '</td>';
  743. if (!$i) {
  744. $totalarray['nbfield']++;
  745. }
  746. }
  747. if (!empty($arrayfields['pr.ref']['checked'])) {
  748. print '<td>';
  749. $projetstatic->id = $obj->projet_id;
  750. $projetstatic->ref = $obj->projet_ref;
  751. $projetstatic->title = $obj->projet_title;
  752. if ($projetstatic->id > 0) {
  753. print $projetstatic->getNomUrl(1, '');
  754. }
  755. print '</td>';
  756. if (!$i) {
  757. $totalarray['nbfield']++;
  758. }
  759. }
  760. if (!empty($arrayfields['c.ref']['checked'])) {
  761. print '<td>';
  762. $contratstatic->id = $obj->contrat_id;
  763. $contratstatic->ref = $obj->contrat_ref;
  764. $contratstatic->ref_customer = $obj->contrat_ref_customer;
  765. $contratstatic->ref_supplier = $obj->contrat_ref_supplier;
  766. if ($contratstatic->id > 0) {
  767. print $contratstatic->getNomUrl(1, '');
  768. print '</td>';
  769. }
  770. if (!$i) {
  771. $totalarray['nbfield']++;
  772. }
  773. }
  774. if (!empty($arrayfields['f.description']['checked'])) {
  775. print '<td>'.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).'</td>';
  776. if (!$i) {
  777. $totalarray['nbfield']++;
  778. }
  779. }
  780. // Extra fields
  781. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  782. // Fields from hook
  783. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  784. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  785. print $hookmanager->resPrint;
  786. // Date creation
  787. if (!empty($arrayfields['f.datec']['checked'])) {
  788. print '<td class="center">';
  789. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  790. print '</td>';
  791. if (!$i) {
  792. $totalarray['nbfield']++;
  793. }
  794. }
  795. // Date modification
  796. if (!empty($arrayfields['f.tms']['checked'])) {
  797. print '<td class="center">';
  798. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  799. print '</td>';
  800. if (!$i) {
  801. $totalarray['nbfield']++;
  802. }
  803. }
  804. // Note public
  805. if (!empty($arrayfields['f.note_public']['checked'])) {
  806. print '<td class="center">';
  807. print dol_string_nohtmltag($obj->note_public);
  808. print '</td>';
  809. if (!$i) {
  810. $totalarray['nbfield']++;
  811. }
  812. }
  813. // Note private
  814. if (!empty($arrayfields['f.note_private']['checked'])) {
  815. print '<td class="center">';
  816. print dol_string_nohtmltag($obj->note_private);
  817. print '</td>';
  818. if (!$i) {
  819. $totalarray['nbfield']++;
  820. }
  821. }
  822. // Status
  823. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  824. print '<td class="right">'.$objectstatic->getLibStatut(5).'</td>';
  825. if (!$i) {
  826. $totalarray['nbfield']++;
  827. }
  828. }
  829. // Fields of detail of line
  830. if (!empty($arrayfields['fd.description']['checked'])) {
  831. print '<td>'.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1)), 48).'</td>';
  832. if (!$i) {
  833. $totalarray['nbfield']++;
  834. }
  835. }
  836. if (!empty($arrayfields['fd.date']['checked'])) {
  837. print '<td class="center">'.dol_print_date($db->jdate($obj->dp), 'dayhour')."</td>\n";
  838. if (!$i) {
  839. $totalarray['nbfield']++;
  840. }
  841. }
  842. if (!empty($arrayfields['fd.duree']['checked'])) {
  843. print '<td class="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
  844. if (!$i) {
  845. $totalarray['nbfield']++;
  846. }
  847. if (!$i) {
  848. $totalarray['type'][$totalarray['nbfield']] = 'duration';
  849. }
  850. if (!$i) {
  851. $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
  852. }
  853. $totalarray['val']['fd.duree'] += $obj->duree;
  854. }
  855. // Action column
  856. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  857. print '<td class="nowrap center">';
  858. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  859. $selected = 0;
  860. if (in_array($obj->rowid, $arrayofselected)) {
  861. $selected = 1;
  862. }
  863. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  864. }
  865. print '</td>';
  866. if (!$i) {
  867. $totalarray['nbfield']++;
  868. }
  869. }
  870. print '</tr>'."\n";
  871. $total += $obj->duree;
  872. }
  873. $i++;
  874. }
  875. // Show total line
  876. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  877. // If no record found
  878. if ($num == 0) {
  879. $colspan = 1;
  880. foreach ($arrayfields as $key => $val) {
  881. if (!empty($val['checked'])) {
  882. $colspan++;
  883. }
  884. }
  885. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  886. }
  887. $db->free($resql);
  888. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  889. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  890. print $hookmanager->resPrint;
  891. print '</table>'."\n";
  892. print '</div>'."\n";
  893. print '</form>'."\n";
  894. if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  895. $hidegeneratedfilelistifempty = 1;
  896. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  897. $hidegeneratedfilelistifempty = 0;
  898. }
  899. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  900. $formfile = new FormFile($db);
  901. // Show list of available documents
  902. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  903. $urlsource .= str_replace('&amp;', '&', $param);
  904. $filedir = $diroutputmassaction;
  905. $genallowed = $permissiontoread;
  906. $delallowed = $permissiontoadd;
  907. print $formfile->showdocuments('massfilesarea_interventions', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  908. }
  909. // End of page
  910. llxFooter();
  911. $db->close();