list.php 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  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 (getDolGlobalString('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'=>!getDolGlobalString('FICHINTER_DISABLE_DETAILS') ? 1 : 0),
  121. 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>!getDolGlobalString('FICHINTER_DISABLE_DETAILS') ? 1 : 0),
  122. 'fd.duree'=>array('label'=>'DurationOfLine', 'type'=> 'duration', 'checked'=>1, 'enabled'=>!getDolGlobalString('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 (!getDolGlobalString('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 (!getDolGlobalString('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 (!$user->hasRight('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 (!getDolGlobalString('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 (!$user->hasRight('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. // Search on sale representative
  281. /*
  282. if ($search_sale && $search_sale != '-1') {
  283. if ($search_sale == -2) {
  284. $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
  285. } elseif ($search_sale > 0) {
  286. $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
  287. }
  288. }*/
  289. // Add where from extra fields
  290. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  291. // Add where from hooks
  292. $parameters = array();
  293. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  294. $sql .= $hookmanager->resPrint;
  295. // Add GroupBy from hooks
  296. $parameters = array('search_all' => $search_all, 'fieldstosearchall' => $fieldstosearchall);
  297. $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
  298. $sql .= $hookmanager->resPrint;
  299. // Count total nb of records
  300. $nbtotalofrecords = '';
  301. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  302. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  303. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  304. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  305. $resql = $db->query($sqlforcount);
  306. if ($resql) {
  307. $objforcount = $db->fetch_object($resql);
  308. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  309. } else {
  310. dol_print_error($db);
  311. }
  312. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
  313. $page = 0;
  314. $offset = 0;
  315. }
  316. $db->free($resql);
  317. }
  318. // Complete request and execute it with limit
  319. $sql .= $db->order($sortfield, $sortorder);
  320. if ($limit) {
  321. $sql .= $db->plimit($limit + 1, $offset);
  322. }
  323. $resql = $db->query($sql);
  324. if (!$resql) {
  325. dol_print_error($db);
  326. exit;
  327. }
  328. $num = $db->num_rows($resql);
  329. // Direct jump if only one record found
  330. if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
  331. $obj = $db->fetch_object($resql);
  332. $id = $obj->rowid;
  333. header("Location: ".dol_buildpath('/fichinter/card.php', 1).'?id='.$id);
  334. exit;
  335. }
  336. // Output page
  337. // --------------------------------------------------------------------
  338. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
  339. $arrayofselected = is_array($toselect) ? $toselect : array();
  340. if ($socid > 0) {
  341. $soc = new Societe($db);
  342. $soc->fetch($socid);
  343. if (empty($search_company)) {
  344. $search_company = $soc->name;
  345. }
  346. }
  347. $param = '';
  348. if (!empty($mode)) {
  349. $param .= '&mode='.urlencode($mode);
  350. }
  351. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  352. $param .= '&contextpage='.urlencode($contextpage);
  353. }
  354. if ($limit > 0 && $limit != $conf->liste_limit) {
  355. $param .= '&limit='.((int) $limit);
  356. }
  357. if ($search_all) {
  358. $param .= "&search_all=".urlencode($search_all);
  359. }
  360. if ($socid) {
  361. $param .= "&socid=".urlencode($socid);
  362. }
  363. if ($search_ref) {
  364. $param .= "&search_ref=".urlencode($search_ref);
  365. }
  366. if ($search_ref_client) {
  367. $param .= "&search_ref_client=".urlencode($search_ref_client);
  368. }
  369. if ($search_company) {
  370. $param .= "&search_company=".urlencode($search_company);
  371. }
  372. if ($search_desc) {
  373. $param .= "&search_desc=".urlencode($search_desc);
  374. }
  375. if ($search_status != '' && $search_status > -1) {
  376. $param .= "&search_status=".urlencode($search_status);
  377. }
  378. if ($show_files) {
  379. $param .= '&show_files='.urlencode($show_files);
  380. }
  381. if ($optioncss != '') {
  382. $param .= '&optioncss='.urlencode($optioncss);
  383. }
  384. // Add $param from extra fields
  385. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  386. // Add $param from hooks
  387. $parameters = array();
  388. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  389. $param .= $hookmanager->resPrint;
  390. // List of mass actions available
  391. $arrayofmassactions = array(
  392. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  393. 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  394. //'presend'=>$langs->trans("SendByMail"),
  395. );
  396. if (!empty($permissiontodelete)) {
  397. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  398. }
  399. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  400. $arrayofmassactions = array();
  401. }
  402. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  403. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  404. if ($optioncss != '') {
  405. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  406. }
  407. print '<input type="hidden" name="token" value="'.newToken().'">';
  408. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  409. print '<input type="hidden" name="action" value="list">';
  410. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  411. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  412. print '<input type="hidden" name="page" value="'.$page.'">';
  413. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  414. print '<input type="hidden" name="page_y" value="">';
  415. print '<input type="hidden" name="mode" value="'.$mode.'">';
  416. $newcardbutton = '';
  417. $url = DOL_URL_ROOT.'/fichinter/card.php?action=create';
  418. if (!empty($socid)) {
  419. $url .= '&socid='.$socid;
  420. }
  421. $newcardbutton = '';
  422. $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'));
  423. $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'));
  424. $newcardbutton .= dolGetButtonTitleSeparator();
  425. $newcardbutton .= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('ficheinter', 'creer'));
  426. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  427. $topicmail = "Information";
  428. $modelmail = "intervention";
  429. $objecttmp = new Fichinter($db);
  430. $trackid = 'int'.$object->id;
  431. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  432. if ($search_all) {
  433. $setupstring = '';
  434. foreach ($fieldstosearchall as $key => $val) {
  435. $fieldstosearchall[$key] = $langs->trans($val);
  436. $setupstring .= $key."=".$val.";";
  437. }
  438. print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  439. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
  440. }
  441. $moreforfilter = '';
  442. $parameters = array();
  443. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  444. if (empty($reshook)) {
  445. $moreforfilter .= $hookmanager->resPrint;
  446. } else {
  447. $moreforfilter = $hookmanager->resPrint;
  448. }
  449. if (!empty($moreforfilter)) {
  450. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  451. print $moreforfilter;
  452. $parameters = array();
  453. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  454. print $hookmanager->resPrint;
  455. print '</div>';
  456. }
  457. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  458. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  459. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  460. print '<div class="div-table-responsive">';
  461. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  462. // Fields title search
  463. // --------------------------------------------------------------------
  464. print '<tr class="liste_titre_filter">';
  465. // Action column
  466. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  467. print '<td class="liste_titre center maxwidthsearch">';
  468. $searchpicto = $form->showFilterButtons('left');
  469. print $searchpicto;
  470. print '</td>';
  471. }
  472. if (!empty($arrayfields['f.ref']['checked'])) {
  473. print '<td class="liste_titre">';
  474. print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
  475. print '</td>';
  476. }
  477. if (!empty($arrayfields['f.ref_client']['checked'])) {
  478. print '<td class="liste_titre">';
  479. print '<input type="text" class="flat" name="search_ref_client" value="'.$search_ref_client.'" size="8">';
  480. print '</td>';
  481. }
  482. if (!empty($arrayfields['s.nom']['checked'])) {
  483. print '<td class="liste_titre">';
  484. print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
  485. print '</td>';
  486. }
  487. if (!empty($arrayfields['pr.ref']['checked'])) {
  488. print '<td class="liste_titre">';
  489. print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">';
  490. print '</td>';
  491. }
  492. if (!empty($arrayfields['c.ref']['checked'])) {
  493. print '<td class="liste_titre">';
  494. print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">';
  495. print '</td>';
  496. }
  497. if (!empty($arrayfields['f.description']['checked'])) {
  498. print '<td class="liste_titre">';
  499. print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
  500. print '</td>';
  501. }
  502. // Extra fields
  503. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  504. // Fields from hook
  505. $parameters = array('arrayfields'=>$arrayfields);
  506. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  507. print $hookmanager->resPrint;
  508. if (!empty($arrayfields['f.datec']['checked'])) {
  509. // Date creation
  510. print '<td class="liste_titre">';
  511. print '</td>';
  512. }
  513. if (!empty($arrayfields['f.tms']['checked'])) {
  514. // Date modification
  515. print '<td class="liste_titre">';
  516. print '</td>';
  517. }
  518. if (!empty($arrayfields['f.note_public']['checked'])) {
  519. // Note public
  520. print '<td class="liste_titre">';
  521. print '</td>';
  522. }
  523. if (!empty($arrayfields['f.note_private']['checked'])) {
  524. // Note private
  525. print '<td class="liste_titre">';
  526. print '</td>';
  527. }
  528. // Status
  529. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  530. print '<td class="liste_titre right parentonrightofpage">';
  531. $liststatus = [
  532. $object::STATUS_DRAFT => $langs->transnoentitiesnoconv('Draft'),
  533. $object::STATUS_VALIDATED => $langs->transnoentitiesnoconv('Validated'),
  534. $object::STATUS_BILLED => $langs->transnoentitiesnoconv('StatusInterInvoiced'),
  535. $object::STATUS_CLOSED => $langs->transnoentitiesnoconv('Done'),
  536. ];
  537. if (!getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) {
  538. unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
  539. }
  540. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage');
  541. print '</td>';
  542. }
  543. // Fields of detail line
  544. if (!empty($arrayfields['fd.description']['checked'])) {
  545. print '<td class="liste_titre">&nbsp;</td>';
  546. }
  547. if (!empty($arrayfields['fd.date']['checked'])) {
  548. print '<td class="liste_titre">&nbsp;</td>';
  549. }
  550. if (!empty($arrayfields['fd.duree']['checked'])) {
  551. print '<td class="liste_titre">&nbsp;</td>';
  552. }
  553. // Action column
  554. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  555. print '<td class="liste_titre center maxwidthsearch">';
  556. $searchpicto = $form->showFilterButtons();
  557. print $searchpicto;
  558. print '</td>';
  559. }
  560. print '</tr>'."\n";
  561. $totalarray = array();
  562. $totalarray['nbfield'] = 0;
  563. // Fields title label
  564. // --------------------------------------------------------------------
  565. print '<tr class="liste_titre">';
  566. // Action column
  567. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  568. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  569. $totalarray['nbfield']++;
  570. }
  571. if (!empty($arrayfields['f.ref']['checked'])) {
  572. print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
  573. $totalarray['nbfield']++;
  574. }
  575. if (!empty($arrayfields['f.ref_client']['checked'])) {
  576. print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], "f.ref_client", "", $param, '', $sortfield, $sortorder);
  577. $totalarray['nbfield']++;
  578. }
  579. if (!empty($arrayfields['s.nom']['checked'])) {
  580. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
  581. $totalarray['nbfield']++;
  582. }
  583. if (!empty($arrayfields['pr.ref']['checked'])) {
  584. print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
  585. $totalarray['nbfield']++;
  586. }
  587. if (!empty($arrayfields['c.ref']['checked'])) {
  588. print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
  589. $totalarray['nbfield']++;
  590. }
  591. if (!empty($arrayfields['f.description']['checked'])) {
  592. print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
  593. $totalarray['nbfield']++;
  594. }
  595. // Extra fields
  596. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  597. // Hook fields
  598. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  599. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  600. print $hookmanager->resPrint;
  601. if (!empty($arrayfields['f.datec']['checked'])) {
  602. print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  603. $totalarray['nbfield']++;
  604. }
  605. if (!empty($arrayfields['f.tms']['checked'])) {
  606. print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  607. $totalarray['nbfield']++;
  608. }
  609. if (!empty($arrayfields['f.note_public']['checked'])) {
  610. print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  611. $totalarray['nbfield']++;
  612. }
  613. if (!empty($arrayfields['f.note_private']['checked'])) {
  614. print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  615. $totalarray['nbfield']++;
  616. }
  617. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  618. print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
  619. $totalarray['nbfield']++;
  620. }
  621. if (!empty($arrayfields['fd.description']['checked'])) {
  622. print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
  623. $totalarray['nbfield']++;
  624. }
  625. if (!empty($arrayfields['fd.date']['checked'])) {
  626. print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
  627. $totalarray['nbfield']++;
  628. }
  629. if (!empty($arrayfields['fd.duree']['checked'])) {
  630. print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
  631. $totalarray['nbfield']++;
  632. }
  633. // Action column
  634. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  635. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  636. $totalarray['nbfield']++;
  637. }
  638. print "</tr>\n";
  639. // Loop on record
  640. // --------------------------------------------------------------------
  641. $i = 0;
  642. $savnbfield = $totalarray['nbfield'];
  643. $totalarray = array();
  644. $totalarray['nbfield'] = 0;
  645. $totalarray['val'] = array();
  646. $totalarray['val']['fd.duree'] = 0;
  647. $total = 0;
  648. $imaxinloop = ($limit ? min($num, $limit) : $num);
  649. while ($i < $imaxinloop) {
  650. $obj = $db->fetch_object($resql);
  651. if (empty($obj)) {
  652. break; // Should not happen
  653. }
  654. // Store properties in $object
  655. //$object->setVarsFromFetchObj($obj);
  656. $objectstatic->id = $obj->rowid;
  657. $objectstatic->ref = $obj->ref;
  658. $objectstatic->ref_client = $obj->ref_client;
  659. $objectstatic->statut = $obj->status; // deprecated
  660. $objectstatic->status = $obj->status;
  661. $companystatic->name = $obj->name;
  662. $companystatic->id = $obj->socid;
  663. $companystatic->client = $obj->client;
  664. $companystatic->fournisseur = $obj->fournisseur;
  665. $companystatic->email = $obj->email;
  666. $companystatic->status = $obj->thirdpartystatus;
  667. //mode kanban
  668. if ($mode == 'kanban') {
  669. if ($i == 0) {
  670. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  671. print '<div class="box-flex-container kanban">';
  672. }
  673. // Output Kanban
  674. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  675. $selected = 0;
  676. if (in_array($object->id, $arrayofselected)) {
  677. $selected = 1;
  678. }
  679. }
  680. $objectstatic->duration = $obj->duree;
  681. $arraydata['thirdparty'] = $companystatic;
  682. print $objectstatic->getKanbanView('', $arraydata);
  683. if ($i == ($imaxinloop - 1)) {
  684. print '</div>';
  685. print '</td></tr>';
  686. }
  687. } else {
  688. // Show here line of result
  689. $j = 0;
  690. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  691. // Action column
  692. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  693. print '<td class="nowrap center">';
  694. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  695. $selected = 0;
  696. if (in_array($obj->rowid, $arrayofselected)) {
  697. $selected = 1;
  698. }
  699. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  700. }
  701. print '</td>';
  702. if (!$i) {
  703. $totalarray['nbfield']++;
  704. }
  705. }
  706. if (!empty($arrayfields['f.ref']['checked'])) {
  707. print "<td>";
  708. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  709. // Picto + Ref
  710. print '<td class="nobordernopadding nowraponall">';
  711. print $objectstatic->getNomUrl(1);
  712. print '</td>';
  713. // Warning
  714. $warnornote = '';
  715. //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
  716. if (!empty($obj->note_private)) {
  717. $warnornote .= ($warnornote ? ' ' : '');
  718. $warnornote .= '<span class="note">';
  719. $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
  720. $warnornote .= '</span>';
  721. }
  722. if ($warnornote) {
  723. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  724. print $warnornote;
  725. print '</td>';
  726. }
  727. // Other picto tool
  728. print '<td width="16" class="right nobordernopadding hideonsmartphone">';
  729. $filename = dol_sanitizeFileName($obj->ref);
  730. $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
  731. $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  732. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  733. print '</td></tr></table>';
  734. print "</td>\n";
  735. if (!$i) {
  736. $totalarray['nbfield']++;
  737. }
  738. }
  739. if (!empty($arrayfields['f.ref_client']['checked'])) {
  740. // Customer ref
  741. print '<td class="nowrap tdoverflowmax200">';
  742. print dol_escape_htmltag($obj->ref_client);
  743. print '</td>';
  744. if (!$i) {
  745. $totalarray['nbfield']++;
  746. }
  747. }
  748. if (!empty($arrayfields['s.nom']['checked'])) {
  749. print '<td>';
  750. print $companystatic->getNomUrl(1, '', 44);
  751. print '</td>';
  752. if (!$i) {
  753. $totalarray['nbfield']++;
  754. }
  755. }
  756. if (!empty($arrayfields['pr.ref']['checked'])) {
  757. print '<td>';
  758. $projetstatic->id = $obj->projet_id;
  759. $projetstatic->ref = $obj->projet_ref;
  760. $projetstatic->title = $obj->projet_title;
  761. if ($projetstatic->id > 0) {
  762. print $projetstatic->getNomUrl(1, '');
  763. }
  764. print '</td>';
  765. if (!$i) {
  766. $totalarray['nbfield']++;
  767. }
  768. }
  769. if (!empty($arrayfields['c.ref']['checked'])) {
  770. print '<td>';
  771. $contratstatic->id = $obj->contrat_id;
  772. $contratstatic->ref = $obj->contrat_ref;
  773. $contratstatic->ref_customer = $obj->contrat_ref_customer;
  774. $contratstatic->ref_supplier = $obj->contrat_ref_supplier;
  775. if ($contratstatic->id > 0) {
  776. print $contratstatic->getNomUrl(1, '');
  777. print '</td>';
  778. }
  779. if (!$i) {
  780. $totalarray['nbfield']++;
  781. }
  782. }
  783. if (!empty($arrayfields['f.description']['checked'])) {
  784. print '<td>'.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).'</td>';
  785. if (!$i) {
  786. $totalarray['nbfield']++;
  787. }
  788. }
  789. // Extra fields
  790. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  791. // Fields from hook
  792. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  793. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  794. print $hookmanager->resPrint;
  795. // Date creation
  796. if (!empty($arrayfields['f.datec']['checked'])) {
  797. print '<td class="center">';
  798. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  799. print '</td>';
  800. if (!$i) {
  801. $totalarray['nbfield']++;
  802. }
  803. }
  804. // Date modification
  805. if (!empty($arrayfields['f.tms']['checked'])) {
  806. print '<td class="center">';
  807. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  808. print '</td>';
  809. if (!$i) {
  810. $totalarray['nbfield']++;
  811. }
  812. }
  813. // Note public
  814. if (!empty($arrayfields['f.note_public']['checked'])) {
  815. print '<td class="center">';
  816. print dol_string_nohtmltag($obj->note_public);
  817. print '</td>';
  818. if (!$i) {
  819. $totalarray['nbfield']++;
  820. }
  821. }
  822. // Note private
  823. if (!empty($arrayfields['f.note_private']['checked'])) {
  824. print '<td class="center">';
  825. print dol_string_nohtmltag($obj->note_private);
  826. print '</td>';
  827. if (!$i) {
  828. $totalarray['nbfield']++;
  829. }
  830. }
  831. // Status
  832. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  833. print '<td class="center">'.$objectstatic->getLibStatut(5).'</td>';
  834. if (!$i) {
  835. $totalarray['nbfield']++;
  836. }
  837. }
  838. // Fields of detail of line
  839. if (!empty($arrayfields['fd.description']['checked'])) {
  840. print '<td>'.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1)), 48).'</td>';
  841. if (!$i) {
  842. $totalarray['nbfield']++;
  843. }
  844. }
  845. if (!empty($arrayfields['fd.date']['checked'])) {
  846. print '<td class="center">'.dol_print_date($db->jdate($obj->dp), 'dayhour')."</td>\n";
  847. if (!$i) {
  848. $totalarray['nbfield']++;
  849. }
  850. }
  851. if (!empty($arrayfields['fd.duree']['checked'])) {
  852. print '<td class="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
  853. if (!$i) {
  854. $totalarray['nbfield']++;
  855. }
  856. if (!$i) {
  857. $totalarray['type'][$totalarray['nbfield']] = 'duration';
  858. }
  859. if (!$i) {
  860. $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
  861. }
  862. $totalarray['val']['fd.duree'] += $obj->duree;
  863. }
  864. // Action column
  865. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  866. print '<td class="nowrap center">';
  867. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  868. $selected = 0;
  869. if (in_array($obj->rowid, $arrayofselected)) {
  870. $selected = 1;
  871. }
  872. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  873. }
  874. print '</td>';
  875. if (!$i) {
  876. $totalarray['nbfield']++;
  877. }
  878. }
  879. print '</tr>'."\n";
  880. $total += $obj->duree;
  881. }
  882. $i++;
  883. }
  884. // Show total line
  885. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  886. // If no record found
  887. if ($num == 0) {
  888. $colspan = 1;
  889. foreach ($arrayfields as $key => $val) {
  890. if (!empty($val['checked'])) {
  891. $colspan++;
  892. }
  893. }
  894. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  895. }
  896. $db->free($resql);
  897. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  898. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  899. print $hookmanager->resPrint;
  900. print '</table>'."\n";
  901. print '</div>'."\n";
  902. print '</form>'."\n";
  903. if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  904. $hidegeneratedfilelistifempty = 1;
  905. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  906. $hidegeneratedfilelistifempty = 0;
  907. }
  908. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  909. $formfile = new FormFile($db);
  910. // Show list of available documents
  911. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  912. $urlsource .= str_replace('&amp;', '&', $param);
  913. $filedir = $diroutputmassaction;
  914. $genallowed = $permissiontoread;
  915. $delallowed = $permissiontoadd;
  916. print $formfile->showdocuments('massfilesarea_interventions', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  917. }
  918. // End of page
  919. llxFooter();
  920. $db->close();