list.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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@capnetworks.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. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/fichinter/list.php
  24. * \brief List of all interventions
  25. * \ingroup ficheinter
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  32. $langs->load("companies");
  33. $langs->load("bills");
  34. $langs->load("interventions");
  35. $action=GETPOST('action','alpha');
  36. $massaction=GETPOST('massaction','alpha');
  37. $show_files=GETPOST('show_files','int');
  38. $confirm=GETPOST('confirm','alpha');
  39. $toselect = GETPOST('toselect', 'array');
  40. $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha');
  41. $search_company=GETPOST('search_company','alpha');
  42. $search_desc=GETPOST('search_desc','alpha');
  43. $search_status=GETPOST('search_status');
  44. $sall=GETPOST('sall');
  45. $optioncss = GETPOST('optioncss','alpha');
  46. $socid=GETPOST('socid','int');
  47. // Security check
  48. $id = GETPOST('id','int');
  49. if ($user->societe_id) $socid=$user->societe_id;
  50. $result = restrictedArea($user, 'ficheinter', $id,'fichinter');
  51. $diroutputmassaction=$conf->ficheinter->dir_output . '/temp/massgeneration/'.$user->id;
  52. $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
  53. $sortfield = GETPOST('sortfield','alpha');
  54. $sortorder = GETPOST('sortorder','alpha');
  55. $page = GETPOST('page','int');
  56. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  57. $offset = $limit * $page;
  58. $pageprev = $page - 1;
  59. $pagenext = $page + 1;
  60. if (! $sortorder) $sortorder="DESC";
  61. if (! $sortfield)
  62. {
  63. if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sortfield="fd.date";
  64. else $sortfield="f.ref";
  65. }
  66. // Initialize technical object to manage context to save list fields
  67. $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'interventionlist';
  68. $sall=GETPOST('sall', 'alphanohtml');
  69. $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha');
  70. $search_company=GETPOST('search_company','alpha');
  71. $search_desc=GETPOST('search_desc','alpha');
  72. $search_status=GETPOST('search_status');
  73. $optioncss = GETPOST('optioncss','alpha');
  74. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  75. $hookmanager->initHooks(array($contextpage));
  76. $extrafields = new ExtraFields($db);
  77. // fetch optionals attributes and labels
  78. $extralabels = $extrafields->fetch_name_optionals_label('fichinter');
  79. $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
  80. // List of fields to search into when doing a "search in all"
  81. $fieldstosearchall = array(
  82. 'f.ref'=>'Ref',
  83. 's.nom'=>"ThirdParty",
  84. 'f.description'=>'Description',
  85. 'f.note_public'=>'NotePublic',
  86. );
  87. if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate";
  88. if (! empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['f.description']);
  89. // Definition of fields for list
  90. $arrayfields=array(
  91. 'f.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  92. 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
  93. 'f.fk_project'=>array('label'=>$langs->trans("Project"), 'checked'=>1),
  94. 'f.fk_contrat'=>array('label'=>$langs->trans("Contract"), 'checked'=>1),
  95. 'f.description'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
  96. 'fd.description'=>array('label'=>"xx", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0),
  97. 'fd.date'=>array('label'=>$langs->trans("Date"), 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0),
  98. 'fd.duree'=>array('label'=>$langs->trans("Duration"), 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0),
  99. 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  100. 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  101. 'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  102. );
  103. // Extra fields
  104. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  105. {
  106. foreach($extrafields->attribute_label as $key => $val)
  107. {
  108. $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
  109. }
  110. }
  111. /*
  112. * Actions
  113. */
  114. if (GETPOST('cancel')) { $action='list'; $massaction=''; }
  115. if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
  116. $parameters=array('socid'=>$socid);
  117. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  118. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  119. if (empty($reshook))
  120. {
  121. // Selection of new fields
  122. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  123. // Purge search criteria
  124. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
  125. {
  126. $search_ref="";
  127. $search_company="";
  128. $search_project="";
  129. $search_contract="";
  130. $search_desc="";
  131. $search_status="";
  132. $toselect='';
  133. $search_array_options=array();
  134. }
  135. // Mass actions
  136. $objectclass='Fichinter';
  137. $objectlabel='Interventions';
  138. $permtoread = $user->rights->ficheinter->lire;
  139. $permtodelete = $user->rights->ficheinter->supprimer;
  140. $uploaddir = $conf->ficheinter->dir_output;
  141. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  142. }
  143. /*
  144. * View
  145. */
  146. $now=dol_now();
  147. $form = new Form($db);
  148. $formfile = new FormFile($db);
  149. $objectstatic=new Fichinter($db);
  150. $companystatic=new Societe($db);
  151. $title=$langs->trans("ListOfInterventions");
  152. llxHeader('', $title);
  153. $sql = "SELECT";
  154. $sql.= " f.ref, f.rowid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update, f.note_private,";
  155. if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql.= " fd.description as descriptiondetail, fd.date as dp, fd.duree,";
  156. $sql.= " s.nom as name, s.rowid as socid, s.client";
  157. // Add fields from extrafields
  158. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  159. // Add fields from hooks
  160. $parameters=array();
  161. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  162. $sql.=$hookmanager->resPrint;
  163. $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
  164. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinter_extrafields as ef on (f.rowid = ef.fk_object)";
  165. if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
  166. if (! $user->rights->societe->client->voir && empty($socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  167. $sql.= ", ".MAIN_DB_PREFIX."societe as s";
  168. $sql.= " WHERE f.fk_soc = s.rowid ";
  169. $sql.= " AND f.entity = ".$conf->entity;
  170. if ($search_ref) {
  171. $sql .= natural_search('f.ref', $search_ref);
  172. }
  173. if ($search_company) {
  174. $sql .= natural_search('s.nom', $search_company);
  175. }
  176. if ($search_desc) {
  177. if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
  178. else $sql .= natural_search(array('f.description'), $search_desc);
  179. }
  180. if ($search_status != '' && $search_status >= 0) {
  181. $sql .= ' AND f.fk_statut = '.$search_status;
  182. }
  183. if (! $user->rights->societe->client->voir && empty($socid))
  184. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  185. if ($socid)
  186. $sql.= " AND s.rowid = " . $socid;
  187. if ($sall) {
  188. $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  189. }
  190. // Add where from extra fields
  191. foreach ($search_array_options as $key => $val)
  192. {
  193. $crit=$val;
  194. $tmpkey=preg_replace('/search_options_/','',$key);
  195. $typ=$extrafields->attribute_type[$tmpkey];
  196. $mode=0;
  197. if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
  198. if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
  199. {
  200. $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
  201. }
  202. }
  203. // Add where from hooks
  204. $parameters=array();
  205. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  206. $sql.=$hookmanager->resPrint;
  207. $sql.= $db->order($sortfield,$sortorder);
  208. // Count total nb of records
  209. $nbtotalofrecords = '';
  210. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  211. {
  212. $result = $db->query($sql);
  213. $nbtotalofrecords = $db->num_rows($result);
  214. }
  215. $sql.= $db->plimit($limit+1, $offset);
  216. //print $sql;
  217. $resql=$db->query($sql);
  218. if ($resql)
  219. {
  220. $num = $db->num_rows($resql);
  221. $arrayofselected=is_array($toselect)?$toselect:array();
  222. $param='';
  223. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  224. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  225. if ($sall) $urlparam.="&sall=".$sall;
  226. if ($socid) $param.="&socid=".$socid;
  227. if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
  228. if ($search_company) $param.="&search_company=".urlencode($search_company);
  229. if ($search_desc) $param.="&search_desc=".urlencode($search_desc);
  230. if ($search_status != '' && $search_status > -1) $param.="&search_status=".urlencode($search_status);
  231. if ($show_files) $param.='&show_files=' .$show_files;
  232. if ($optioncss != '') $param.='&optioncss='.$optioncss;
  233. // Add $param from extra fields
  234. foreach ($search_array_options as $key => $val)
  235. {
  236. $crit=$val;
  237. $tmpkey=preg_replace('/search_options_/','',$key);
  238. if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
  239. }
  240. // List of mass actions available
  241. $arrayofmassactions = array(
  242. //'presend'=>$langs->trans("SendByMail"),
  243. 'builddoc'=>$langs->trans("PDFMerge"),
  244. );
  245. //if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
  246. if ($user->rights->ficheinter->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
  247. //if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
  248. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  249. // Lines of title fields
  250. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  251. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  252. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  253. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  254. print '<input type="hidden" name="action" value="list">';
  255. print '<input type="hidden" name="page" value="'.$page.'">';
  256. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  257. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  258. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  259. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
  260. if ($sall)
  261. {
  262. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  263. print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
  264. }
  265. $moreforfilter='';
  266. $parameters=array();
  267. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  268. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  269. else $moreforfilter = $hookmanager->resPrint;
  270. if (! empty($moreforfilter))
  271. {
  272. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  273. print $moreforfilter;
  274. print '</div>';
  275. }
  276. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  277. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  278. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  279. print '<div class="div-table-responsive">';
  280. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  281. print '<tr class="liste_titre_filter">';
  282. if (! empty($arrayfields['f.ref']['checked']))
  283. {
  284. print '<td class="liste_titre">';
  285. print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
  286. print '</td>';
  287. }
  288. if (! empty($arrayfields['s.nom']['checked']))
  289. {
  290. print '<td class="liste_titre">';
  291. print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
  292. print '</td>';
  293. }
  294. if (! empty($arrayfields['f.description']['checked']))
  295. {
  296. print '<td class="liste_titre">';
  297. print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
  298. print '</td>';
  299. }
  300. if (! empty($arrayfields['fd.description']['checked']))
  301. {
  302. // Desc of line
  303. print '<td class="liste_titre">&nbsp;</td>';
  304. }
  305. if (! empty($arrayfields['fd.date']['checked']))
  306. {
  307. print '<td class="liste_titre">&nbsp;</td>';
  308. }
  309. if (! empty($arrayfields['fd.duree']['checked']))
  310. {
  311. print '<td class="liste_titre">&nbsp;</td>';
  312. }
  313. // Extra fields
  314. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  315. {
  316. foreach($extrafields->attribute_label as $key => $val)
  317. {
  318. if (! empty($arrayfields["ef.".$key]['checked']))
  319. {
  320. $align=$extrafields->getAlignFlag($key);
  321. $typeofextrafield=$extrafields->attribute_type[$key];
  322. print '<td class="liste_titre'.($align?' '.$align:'').'">';
  323. if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
  324. {
  325. $crit=$val;
  326. $tmpkey=preg_replace('/search_options_/','',$key);
  327. $searchclass='';
  328. if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
  329. if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
  330. print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
  331. }
  332. print '</td>';
  333. }
  334. }
  335. }
  336. // Fields from hook
  337. $parameters=array('arrayfields'=>$arrayfields);
  338. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  339. print $hookmanager->resPrint;
  340. if (! empty($arrayfields['f.datec']['checked']))
  341. {
  342. // Date creation
  343. print '<td class="liste_titre">';
  344. print '</td>';
  345. }
  346. if (! empty($arrayfields['f.tms']['checked']))
  347. {
  348. // Date modification
  349. print '<td class="liste_titre">';
  350. print '</td>';
  351. }
  352. // Status
  353. if (! empty($arrayfields['f.fk_statut']['checked']))
  354. {
  355. print '<td class="liste_titre" align="right">';
  356. $liststatus=$objectstatic->statuts_short;
  357. if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
  358. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1);
  359. print '</td>';
  360. }
  361. print '<td class="liste_titre" align="right">';
  362. $searchpicto=$form->showFilterButtons();
  363. print $searchpicto;
  364. print '</td>';
  365. print "</tr>\n";
  366. print '<tr class="liste_titre">';
  367. if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.ref","",$param,'',$sortfield,$sortorder);
  368. if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,'',$sortfield,$sortorder);
  369. if (! empty($arrayfields['f.description']['checked'])) print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"f.description","",$param,'',$sortfield,$sortorder);
  370. if (! empty($arrayfields['fd.description']['checked'])) print_liste_field_titre('',$_SERVER["PHP_SELF"],'');
  371. if (! empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"fd.date","",$param,'align="center"',$sortfield,$sortorder);
  372. if (! empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],"fd.duree","",$param,'align="right"',$sortfield,$sortorder);
  373. // Extra fields
  374. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  375. {
  376. foreach($extrafields->attribute_label as $key => $val)
  377. {
  378. if (! empty($arrayfields["ef.".$key]['checked']))
  379. {
  380. $align=$extrafields->getAlignFlag($key);
  381. print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
  382. }
  383. }
  384. }
  385. // Hook fields
  386. $parameters=array('arrayfields'=>$arrayfields);
  387. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  388. print $hookmanager->resPrint;
  389. if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  390. if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  391. if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
  392. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  393. print "</tr>\n";
  394. $total = 0;
  395. $i = 0;
  396. $totalarray=array();
  397. while ($i < min($num, $limit))
  398. {
  399. $obj = $db->fetch_object($resql);
  400. $objectstatic->id=$obj->rowid;
  401. $objectstatic->ref=$obj->ref;
  402. $objectstatic->statut=$obj->fk_statut;
  403. print '<tr class="oddeven">';
  404. if (! empty($arrayfields['f.ref']['checked']))
  405. {
  406. print "<td>";
  407. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  408. // Picto + Ref
  409. print '<td class="nobordernopadding nowrap">';
  410. print $objectstatic->getNomUrl(1);
  411. print '</td>';
  412. // Warning
  413. $warnornote='';
  414. //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
  415. if (! empty($obj->note_private))
  416. {
  417. $warnornote.=($warnornote?' ':'');
  418. $warnornote.= '<span class="note">';
  419. $warnornote.= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
  420. $warnornote.= '</span>';
  421. }
  422. if ($warnornote)
  423. {
  424. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  425. print $warnornote;
  426. print '</td>';
  427. }
  428. // Other picto tool
  429. print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
  430. $filename=dol_sanitizeFileName($obj->ref);
  431. $filedir=$conf->ficheinter->dir_output . '/' . dol_sanitizeFileName($obj->ref);
  432. $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  433. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  434. print '</td></tr></table>';
  435. print "</td>\n";
  436. if (! $i) $totalarray['nbfield']++;
  437. }
  438. if (! empty($arrayfields['s.nom']['checked']))
  439. {
  440. print '<td>';
  441. $companystatic->name=$obj->name;
  442. $companystatic->id=$obj->socid;
  443. $companystatic->client=$obj->client;
  444. print $companystatic->getNomUrl(1,'',44);
  445. print '</td>';
  446. if (! $i) $totalarray['nbfield']++;
  447. }
  448. if (! empty($arrayfields['f.description']['checked']))
  449. {
  450. print '<td>'.dol_trunc(dolGetFirstLineOfText($obj->description),48).'</td>';
  451. if (! $i) $totalarray['nbfield']++;
  452. }
  453. if (! empty($arrayfields['fd.description']['checked']))
  454. {
  455. //print '<td>'.dol_trunc(dol_escape_htmltag(dolGetFirstLineOfText($obj->descriptiondetail)),48).'</td>';
  456. print '<td>'.dolGetFirstLineOfText($obj->descriptiondetail).'</td>';
  457. if (! $i) $totalarray['nbfield']++;
  458. }
  459. if (! empty($arrayfields['fd.date']['checked']))
  460. {
  461. print '<td align="center">'.dol_print_date($db->jdate($obj->dp),'dayhour')."</td>\n";
  462. if (! $i) $totalarray['nbfield']++;
  463. }
  464. if (! empty($arrayfields['fd.duree']['checked']))
  465. {
  466. print '<td align="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
  467. if (! $i) $totalarray['nbfield']++;
  468. if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield'];
  469. $totalarray['totalduration']+=$obj->duree;
  470. }
  471. // Extra fields
  472. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  473. {
  474. foreach($extrafields->attribute_label as $key => $val)
  475. {
  476. if (! empty($arrayfields["ef.".$key]['checked']))
  477. {
  478. print '<td';
  479. $align=$extrafields->getAlignFlag($key);
  480. if ($align) print ' align="'.$align.'"';
  481. print '>';
  482. $tmpkey='options_'.$key;
  483. print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
  484. print '</td>';
  485. if (! $i) $totalarray['nbfield']++;
  486. }
  487. }
  488. }
  489. // Fields from hook
  490. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  491. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  492. print $hookmanager->resPrint;
  493. // Date creation
  494. if (! empty($arrayfields['f.datec']['checked']))
  495. {
  496. print '<td align="center">';
  497. print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
  498. print '</td>';
  499. if (! $i) $totalarray['nbfield']++;
  500. }
  501. // Date modification
  502. if (! empty($arrayfields['f.tms']['checked']))
  503. {
  504. print '<td align="center">';
  505. print dol_print_date($db->jdate($obj->date_update), 'dayhour');
  506. print '</td>';
  507. if (! $i) $totalarray['nbfield']++;
  508. }
  509. // Status
  510. if (! empty($arrayfields['f.fk_statut']['checked']))
  511. {
  512. print '<td align="right">'.$objectstatic->LibStatut($obj->fk_statut,5).'</td>';
  513. if (! $i) $totalarray['nbfield']++;
  514. }
  515. // Action column
  516. print '<td class="nowrap" align="center">';
  517. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  518. {
  519. $selected=0;
  520. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  521. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  522. }
  523. print '</td>';
  524. if (! $i) $totalarray['nbfield']++;
  525. print "</tr>\n";
  526. $total += $obj->duree;
  527. $i++;
  528. }
  529. // Show total line
  530. if (isset($totalarray['totalduration']))
  531. {
  532. print '<tr class="liste_total">';
  533. $i=0;
  534. while ($i < $totalarray['nbfield'])
  535. {
  536. $i++;
  537. if ($i == 1)
  538. {
  539. if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
  540. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  541. }
  542. elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>';
  543. else print '<td></td>';
  544. }
  545. print '</tr>';
  546. }
  547. $db->free($resql);
  548. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  549. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  550. print $hookmanager->resPrint;
  551. print '</table>'."\n";
  552. print '</div>';
  553. print "</form>\n";
  554. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
  555. {
  556. /*
  557. * Show list of available documents
  558. */
  559. $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  560. $urlsource.=str_replace('&amp;','&',$param);
  561. $filedir=$diroutputmassaction;
  562. $genallowed=$user->rights->ficheinter->lire;
  563. $delallowed=$user->rights->ficheinter->supprimer;
  564. print $formfile->showdocuments('massfilesarea_interventions','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
  565. }
  566. else
  567. {
  568. print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
  569. }
  570. }
  571. else
  572. {
  573. dol_print_error($db);
  574. }
  575. llxFooter();
  576. $db->close();