list.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/fichinter/list.php
  25. * \brief List of all interventions
  26. * \ingroup ficheinter
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  33. // Load translation files required by the page
  34. $langs->loadLangs(array('companies', 'bills', '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. $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'interventionlist';
  41. $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha');
  42. $search_company=GETPOST('search_company','alpha');
  43. $search_desc=GETPOST('search_desc','alpha');
  44. $search_status=GETPOST('search_status');
  45. $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
  46. $optioncss = GETPOST('optioncss','alpha');
  47. $socid=GETPOST('socid','int');
  48. // Security check
  49. $id = GETPOST('id','int');
  50. if ($user->societe_id) $socid=$user->societe_id;
  51. $result = restrictedArea($user, 'ficheinter', $id,'fichinter');
  52. $diroutputmassaction=$conf->ficheinter->dir_output . '/temp/massgeneration/'.$user->id;
  53. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  54. $sortfield = GETPOST('sortfield','alpha');
  55. $sortorder = GETPOST('sortorder','alpha');
  56. $page = GETPOST('page','int');
  57. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  58. $offset = $limit * $page;
  59. $pageprev = $page - 1;
  60. $pagenext = $page + 1;
  61. if (! $sortorder) $sortorder="DESC";
  62. if (! $sortfield)
  63. {
  64. if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sortfield="fd.date";
  65. else $sortfield="f.ref";
  66. }
  67. $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
  68. $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha');
  69. $search_company=GETPOST('search_company','alpha');
  70. $search_desc=GETPOST('search_desc','alpha');
  71. $search_status=GETPOST('search_status');
  72. $optioncss = GETPOST('optioncss','alpha');
  73. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  74. $object = new Fichinter($db);
  75. $hookmanager->initHooks(array('interventionlist'));
  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($object->table_element,'','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. if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
  109. }
  110. }
  111. /*
  112. * Actions
  113. */
  114. if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
  115. if (! GETPOST('confirmmassaction','alpha') && $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','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // 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.entity IN (".getEntity('intervention').")";
  169. $sql.= " AND f.fk_soc = s.rowid";
  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. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  192. // Add where from hooks
  193. $parameters=array();
  194. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  195. $sql.=$hookmanager->resPrint;
  196. $sql.= $db->order($sortfield,$sortorder);
  197. // Count total nb of records
  198. $nbtotalofrecords = '';
  199. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  200. {
  201. $result = $db->query($sql);
  202. $nbtotalofrecords = $db->num_rows($result);
  203. if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
  204. {
  205. $page = 0;
  206. $offset = 0;
  207. }
  208. }
  209. $sql.= $db->plimit($limit+1, $offset);
  210. //print $sql;
  211. $resql=$db->query($sql);
  212. if ($resql)
  213. {
  214. $num = $db->num_rows($resql);
  215. $arrayofselected=is_array($toselect)?$toselect:array();
  216. if ($socid > 0)
  217. {
  218. $soc = new Societe($db);
  219. $soc->fetch($socid);
  220. if (empty($search_company)) $search_company = $soc->name;
  221. }
  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. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  235. // List of mass actions available
  236. $arrayofmassactions = array(
  237. //'presend'=>$langs->trans("SendByMail"),
  238. 'builddoc'=>$langs->trans("PDFMerge"),
  239. );
  240. if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
  241. if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
  242. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  243. $newcardbutton='';
  244. if ($user->rights->ficheinter->creer)
  245. {
  246. $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/fichinter/card.php?action=create"><span class="valignmiddle">'.$langs->trans('NewIntervention').'</span>';
  247. $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
  248. $newcardbutton.= '</a>';
  249. }
  250. // Lines of title fields
  251. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  252. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  253. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  254. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  255. print '<input type="hidden" name="action" value="list">';
  256. print '<input type="hidden" name="page" value="'.$page.'">';
  257. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  258. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  259. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  260. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit);
  261. $topicmail="Information";
  262. $modelmail="intervention";
  263. $objecttmp=new Fichinter($db);
  264. $trackid='int'.$object->id;
  265. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  266. if ($sall)
  267. {
  268. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  269. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
  270. }
  271. $moreforfilter='';
  272. $parameters=array();
  273. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  274. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  275. else $moreforfilter = $hookmanager->resPrint;
  276. if (! empty($moreforfilter))
  277. {
  278. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  279. print $moreforfilter;
  280. print '</div>';
  281. }
  282. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  283. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  284. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  285. print '<div class="div-table-responsive">';
  286. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  287. print '<tr class="liste_titre_filter">';
  288. if (! empty($arrayfields['f.ref']['checked']))
  289. {
  290. print '<td class="liste_titre">';
  291. print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
  292. print '</td>';
  293. }
  294. if (! empty($arrayfields['s.nom']['checked']))
  295. {
  296. print '<td class="liste_titre">';
  297. print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
  298. print '</td>';
  299. }
  300. if (! empty($arrayfields['f.description']['checked']))
  301. {
  302. print '<td class="liste_titre">';
  303. print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
  304. print '</td>';
  305. }
  306. if (! empty($arrayfields['fd.description']['checked']))
  307. {
  308. // Desc of line
  309. print '<td class="liste_titre">&nbsp;</td>';
  310. }
  311. if (! empty($arrayfields['fd.date']['checked']))
  312. {
  313. print '<td class="liste_titre">&nbsp;</td>';
  314. }
  315. if (! empty($arrayfields['fd.duree']['checked']))
  316. {
  317. print '<td class="liste_titre">&nbsp;</td>';
  318. }
  319. // Extra fields
  320. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  321. // Fields from hook
  322. $parameters=array('arrayfields'=>$arrayfields);
  323. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  324. print $hookmanager->resPrint;
  325. if (! empty($arrayfields['f.datec']['checked']))
  326. {
  327. // Date creation
  328. print '<td class="liste_titre">';
  329. print '</td>';
  330. }
  331. if (! empty($arrayfields['f.tms']['checked']))
  332. {
  333. // Date modification
  334. print '<td class="liste_titre">';
  335. print '</td>';
  336. }
  337. // Status
  338. if (! empty($arrayfields['f.fk_statut']['checked']))
  339. {
  340. print '<td class="liste_titre" align="right">';
  341. $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short
  342. $liststatus=$objectstatic->statuts_short;
  343. 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
  344. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1);
  345. print '</td>';
  346. }
  347. print '<td class="liste_titre" align="right">';
  348. $searchpicto=$form->showFilterButtons();
  349. print $searchpicto;
  350. print '</td>';
  351. print "</tr>\n";
  352. print '<tr class="liste_titre">';
  353. if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"f.ref","",$param,'',$sortfield,$sortorder);
  354. if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom","",$param,'',$sortfield,$sortorder);
  355. if (! empty($arrayfields['f.description']['checked'])) print_liste_field_titre("Description",$_SERVER["PHP_SELF"],"f.description","",$param,'',$sortfield,$sortorder);
  356. if (! empty($arrayfields['fd.description']['checked'])) print_liste_field_titre('',$_SERVER["PHP_SELF"],'');
  357. if (! empty($arrayfields['fd.date']['checked'])) print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"fd.date","",$param,'align="center"',$sortfield,$sortorder);
  358. if (! empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],"fd.duree","",$param,'align="right"',$sortfield,$sortorder);
  359. // Extra fields
  360. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  361. // Hook fields
  362. $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
  363. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  364. print $hookmanager->resPrint;
  365. if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre("DateCreationShort",$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  366. if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre("DateModificationShort",$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  367. if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
  368. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  369. print "</tr>\n";
  370. $total = 0;
  371. $i = 0;
  372. $totalarray=array();
  373. while ($i < min($num, $limit))
  374. {
  375. $obj = $db->fetch_object($resql);
  376. $objectstatic->id=$obj->rowid;
  377. $objectstatic->ref=$obj->ref;
  378. $objectstatic->statut=$obj->fk_statut;
  379. print '<tr class="oddeven">';
  380. if (! empty($arrayfields['f.ref']['checked']))
  381. {
  382. print "<td>";
  383. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  384. // Picto + Ref
  385. print '<td class="nobordernopadding nowrap">';
  386. print $objectstatic->getNomUrl(1);
  387. print '</td>';
  388. // Warning
  389. $warnornote='';
  390. //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
  391. if (! empty($obj->note_private))
  392. {
  393. $warnornote.=($warnornote?' ':'');
  394. $warnornote.= '<span class="note">';
  395. $warnornote.= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
  396. $warnornote.= '</span>';
  397. }
  398. if ($warnornote)
  399. {
  400. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  401. print $warnornote;
  402. print '</td>';
  403. }
  404. // Other picto tool
  405. print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
  406. $filename=dol_sanitizeFileName($obj->ref);
  407. $filedir=$conf->ficheinter->dir_output . '/' . dol_sanitizeFileName($obj->ref);
  408. $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  409. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  410. print '</td></tr></table>';
  411. print "</td>\n";
  412. if (! $i) $totalarray['nbfield']++;
  413. }
  414. if (! empty($arrayfields['s.nom']['checked']))
  415. {
  416. print '<td>';
  417. $companystatic->name=$obj->name;
  418. $companystatic->id=$obj->socid;
  419. $companystatic->client=$obj->client;
  420. print $companystatic->getNomUrl(1,'',44);
  421. print '</td>';
  422. if (! $i) $totalarray['nbfield']++;
  423. }
  424. if (! empty($arrayfields['f.description']['checked']))
  425. {
  426. print '<td>'.dol_trunc(dolGetFirstLineOfText($obj->description),48).'</td>';
  427. if (! $i) $totalarray['nbfield']++;
  428. }
  429. if (! empty($arrayfields['fd.description']['checked']))
  430. {
  431. //print '<td>'.dol_trunc(dol_escape_htmltag(dolGetFirstLineOfText($obj->descriptiondetail)),48).'</td>';
  432. print '<td>'.dolGetFirstLineOfText($obj->descriptiondetail).'</td>';
  433. if (! $i) $totalarray['nbfield']++;
  434. }
  435. if (! empty($arrayfields['fd.date']['checked']))
  436. {
  437. print '<td align="center">'.dol_print_date($db->jdate($obj->dp),'dayhour')."</td>\n";
  438. if (! $i) $totalarray['nbfield']++;
  439. }
  440. if (! empty($arrayfields['fd.duree']['checked']))
  441. {
  442. print '<td align="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
  443. if (! $i) $totalarray['nbfield']++;
  444. if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield'];
  445. $totalarray['totalduration']+=$obj->duree;
  446. }
  447. // Extra fields
  448. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  449. // Fields from hook
  450. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  451. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  452. print $hookmanager->resPrint;
  453. // Date creation
  454. if (! empty($arrayfields['f.datec']['checked']))
  455. {
  456. print '<td align="center">';
  457. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  458. print '</td>';
  459. if (! $i) $totalarray['nbfield']++;
  460. }
  461. // Date modification
  462. if (! empty($arrayfields['f.tms']['checked']))
  463. {
  464. print '<td align="center">';
  465. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  466. print '</td>';
  467. if (! $i) $totalarray['nbfield']++;
  468. }
  469. // Status
  470. if (! empty($arrayfields['f.fk_statut']['checked']))
  471. {
  472. print '<td align="right">'.$objectstatic->LibStatut($obj->fk_statut,5).'</td>';
  473. if (! $i) $totalarray['nbfield']++;
  474. }
  475. // Action column
  476. print '<td class="nowrap" align="center">';
  477. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  478. {
  479. $selected=0;
  480. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  481. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  482. }
  483. print '</td>';
  484. if (! $i) $totalarray['nbfield']++;
  485. print "</tr>\n";
  486. $total += $obj->duree;
  487. $i++;
  488. }
  489. // Show total line
  490. if (isset($totalarray['totalduration']))
  491. {
  492. print '<tr class="liste_total">';
  493. $i=0;
  494. while ($i < $totalarray['nbfield'])
  495. {
  496. $i++;
  497. if ($i == 1)
  498. {
  499. if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
  500. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  501. }
  502. elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>';
  503. else print '<td></td>';
  504. }
  505. print '</tr>';
  506. }
  507. $db->free($resql);
  508. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  509. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  510. print $hookmanager->resPrint;
  511. print '</table>'."\n";
  512. print '</div>';
  513. print "</form>\n";
  514. $hidegeneratedfilelistifempty=1;
  515. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
  516. // Show list of available documents
  517. $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  518. $urlsource.=str_replace('&amp;','&',$param);
  519. $filedir=$diroutputmassaction;
  520. $genallowed=$user->rights->ficheinter->lire;
  521. $delallowed=$user->rights->ficheinter->creer;
  522. print $formfile->showdocuments('massfilesarea_interventions','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
  523. }
  524. else
  525. {
  526. dol_print_error($db);
  527. }
  528. llxFooter();
  529. $db->close();