list.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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 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. require '../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  35. if (!empty($conf->projet->enabled)) {
  36. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  37. }
  38. if (!empty($conf->contrat->enabled)) {
  39. require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  40. }
  41. // Load translation files required by the page
  42. $langs->loadLangs(array('companies', 'bills', 'interventions'));
  43. if (!empty($conf->projet->enabled)) {
  44. $langs->load("projects");
  45. }
  46. if (!empty($conf->contrat->enabled)) {
  47. $langs->load("contracts");
  48. }
  49. $action = GETPOST('action', 'aZ09');
  50. $massaction = GETPOST('massaction', 'alpha');
  51. $show_files = GETPOST('show_files', 'int');
  52. $confirm = GETPOST('confirm', 'alpha');
  53. $toselect = GETPOST('toselect', 'array');
  54. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'interventionlist';
  55. $search_ref = GETPOST('search_ref') ?GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha');
  56. $search_company = GETPOST('search_company', 'alpha');
  57. $search_desc = GETPOST('search_desc', 'alpha');
  58. $search_projet_ref = GETPOST('search_projet_ref', 'alpha');
  59. $search_contrat_ref = GETPOST('search_contrat_ref', 'alpha');
  60. $search_status = GETPOST('search_status', 'alpha');
  61. $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  62. $optioncss = GETPOST('optioncss', 'alpha');
  63. $socid = GETPOST('socid', 'int');
  64. // Security check
  65. $id = GETPOST('id', 'int');
  66. if ($user->socid) {
  67. $socid = $user->socid;
  68. }
  69. $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
  70. $diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id;
  71. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  72. $sortfield = GETPOST('sortfield', 'aZ09comma');
  73. $sortorder = GETPOST('sortorder', 'aZ09comma');
  74. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  75. if (empty($page) || $page == -1) {
  76. $page = 0;
  77. } // If $page is not defined, or '' or -1
  78. $offset = $limit * $page;
  79. $pageprev = $page - 1;
  80. $pagenext = $page + 1;
  81. if (!$sortorder) {
  82. $sortorder = "DESC";
  83. }
  84. if (!$sortfield) {
  85. $sortfield = "f.ref";
  86. }
  87. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  88. $object = new Fichinter($db);
  89. $hookmanager->initHooks(array('interventionlist'));
  90. $extrafields = new ExtraFields($db);
  91. // fetch optionals attributes and labels
  92. $extrafields->fetch_name_optionals_label($object->table_element);
  93. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  94. // List of fields to search into when doing a "search in all"
  95. $fieldstosearchall = array(
  96. 'f.ref'=>'Ref',
  97. 's.nom'=>"ThirdParty",
  98. 'f.description'=>'Description',
  99. 'f.note_public'=>'NotePublic',
  100. 'fd.description'=>'DescriptionOfLine',
  101. );
  102. if (empty($user->socid)) {
  103. $fieldstosearchall["f.note_private"] = "NotePrivate";
  104. }
  105. if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
  106. unset($fieldstosearchall['fd.description']);
  107. }
  108. // Definition of fields for list
  109. $arrayfields = array(
  110. 'f.ref'=>array('label'=>'Ref', 'checked'=>1),
  111. 's.nom'=>array('label'=>'ThirdParty', 'checked'=>1),
  112. 'pr.ref'=>array('label'=>'Project', 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 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'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))),
  118. 'f.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))),
  119. 'f.fk_statut'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000),
  120. 'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
  121. 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
  122. 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
  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. /*
  129. * Actions
  130. */
  131. if (GETPOST('cancel', 'alpha')) {
  132. $action = 'list'; $massaction = '';
  133. }
  134. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  135. $massaction = '';
  136. }
  137. $parameters = array('socid'=>$socid);
  138. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  139. if ($reshook < 0) {
  140. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  141. }
  142. if (empty($reshook)) {
  143. // Selection of new fields
  144. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  145. // Purge search criteria
  146. 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
  147. $search_ref = "";
  148. $search_company = "";
  149. $search_projet_ref = "";
  150. $search_contrat_ref = "";
  151. $search_desc = "";
  152. $search_status = "";
  153. $toselect = array();
  154. $search_array_options = array();
  155. }
  156. // Mass actions
  157. $objectclass = 'Fichinter';
  158. $objectlabel = 'Interventions';
  159. $permissiontoread = $user->rights->ficheinter->lire;
  160. $permissiontodelete = $user->rights->ficheinter->supprimer;
  161. $uploaddir = $conf->ficheinter->dir_output;
  162. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  163. }
  164. /*
  165. * View
  166. */
  167. $now = dol_now();
  168. $form = new Form($db);
  169. $formfile = new FormFile($db);
  170. $objectstatic = new Fichinter($db);
  171. $companystatic = new Societe($db);
  172. if (!empty($conf->projet->enabled)) {
  173. $projetstatic = new Project($db);
  174. }
  175. if (!empty($conf->contrat->enabled)) {
  176. $contratstatic = new Contrat($db);
  177. }
  178. $title = $langs->trans("ListOfInterventions");
  179. llxHeader('', $title);
  180. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  181. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  182. $atleastonefieldinlines = 0;
  183. foreach ($arrayfields as $tmpkey => $tmpval) {
  184. if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) {
  185. $atleastonefieldinlines++;
  186. break;
  187. }
  188. }
  189. $sql = "SELECT";
  190. $sql .= " f.ref, 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,";
  191. if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
  192. $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
  193. }
  194. $sql .= " s.nom as name, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus";
  195. if (!empty($conf->projet->enabled)) {
  196. $sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title";
  197. }
  198. if (!empty($conf->contrat->enabled)) {
  199. $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";
  200. }
  201. // Add fields from extrafields
  202. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  203. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  204. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  205. }
  206. }
  207. // Add fields from hooks
  208. $parameters = array();
  209. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  210. $sql .= $hookmanager->resPrint;
  211. $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
  212. if (!empty($conf->projet->enabled)) {
  213. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid";
  214. }
  215. if (!empty($conf->contrat->enabled)) {
  216. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid";
  217. }
  218. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  219. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
  220. }
  221. if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
  222. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
  223. }
  224. // Add table from hooks
  225. $parameters = array();
  226. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  227. $sql .= $hookmanager->resPrint;
  228. if (empty($user->rights->societe->client->voir) && empty($socid)) {
  229. $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  230. }
  231. $sql .= ", ".MAIN_DB_PREFIX."societe as s";
  232. $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
  233. $sql .= " AND f.fk_soc = s.rowid";
  234. if ($search_ref) {
  235. $sql .= natural_search('f.ref', $search_ref);
  236. }
  237. if ($search_company) {
  238. $sql .= natural_search('s.nom', $search_company);
  239. }
  240. if ($search_projet_ref) {
  241. $sql .= natural_search('pr.ref', $search_projet_ref);
  242. }
  243. if ($search_contrat_ref) {
  244. $sql .= natural_search('c.ref', $search_contrat_ref);
  245. }
  246. if ($search_desc) {
  247. if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
  248. $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
  249. } else {
  250. $sql .= natural_search(array('f.description'), $search_desc);
  251. }
  252. }
  253. if ($search_status != '' && $search_status >= 0) {
  254. $sql .= ' AND f.fk_statut = '.urlencode($search_status);
  255. }
  256. if (empty($user->rights->societe->client->voir) && empty($socid)) {
  257. $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
  258. }
  259. if ($socid) {
  260. $sql .= " AND s.rowid = ".((int) $socid);
  261. }
  262. if ($sall) {
  263. $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  264. }
  265. // Add where from extra fields
  266. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  267. // Add where from hooks
  268. $parameters = array();
  269. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  270. $sql .= $hookmanager->resPrint;
  271. // Add GroupBy from hooks
  272. $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall);
  273. $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
  274. $sql .= $hookmanager->resPrint;
  275. $sql .= $db->order($sortfield, $sortorder);
  276. // Count total nb of records
  277. $nbtotalofrecords = '';
  278. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  279. $result = $db->query($sql);
  280. $nbtotalofrecords = $db->num_rows($result);
  281. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  282. $page = 0;
  283. $offset = 0;
  284. }
  285. }
  286. $sql .= $db->plimit($limit + 1, $offset);
  287. //print $sql;
  288. $resql = $db->query($sql);
  289. if ($resql) {
  290. $num = $db->num_rows($resql);
  291. $arrayofselected = is_array($toselect) ? $toselect : array();
  292. if ($socid > 0) {
  293. $soc = new Societe($db);
  294. $soc->fetch($socid);
  295. if (empty($search_company)) {
  296. $search_company = $soc->name;
  297. }
  298. }
  299. $param = '';
  300. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  301. $param .= '&contextpage='.urlencode($contextpage);
  302. }
  303. if ($limit > 0 && $limit != $conf->liste_limit) {
  304. $param .= '&limit='.urlencode($limit);
  305. }
  306. if ($sall) {
  307. $param .= "&sall=".urlencode($sall);
  308. }
  309. if ($socid) {
  310. $param .= "&socid=".urlencode($socid);
  311. }
  312. if ($search_ref) {
  313. $param .= "&search_ref=".urlencode($search_ref);
  314. }
  315. if ($search_company) {
  316. $param .= "&search_company=".urlencode($search_company);
  317. }
  318. if ($search_desc) {
  319. $param .= "&search_desc=".urlencode($search_desc);
  320. }
  321. if ($search_status != '' && $search_status > -1) {
  322. $param .= "&search_status=".urlencode($search_status);
  323. }
  324. if ($show_files) {
  325. $param .= '&show_files='.urlencode($show_files);
  326. }
  327. if ($optioncss != '') {
  328. $param .= '&optioncss='.urlencode($optioncss);
  329. }
  330. // Add $param from extra fields
  331. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  332. // List of mass actions available
  333. $arrayofmassactions = array(
  334. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  335. 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  336. //'presend'=>$langs->trans("SendByMail"),
  337. );
  338. if ($user->rights->ficheinter->supprimer) {
  339. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  340. }
  341. if (in_array($massaction, array('presend', 'predelete'))) {
  342. $arrayofmassactions = array();
  343. }
  344. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  345. $newcardbutton = '';
  346. $url = DOL_URL_ROOT.'/fichinter/card.php?action=create';
  347. if (!empty($socid)) {
  348. $url .= '&socid='.$socid;
  349. }
  350. $newcardbutton = dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer);
  351. // Lines of title fields
  352. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  353. if ($optioncss != '') {
  354. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  355. }
  356. print '<input type="hidden" name="token" value="'.newToken().'">';
  357. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  358. print '<input type="hidden" name="action" value="list">';
  359. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  360. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  361. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  362. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit, 0, 0, 1);
  363. $topicmail = "Information";
  364. $modelmail = "intervention";
  365. $objecttmp = new Fichinter($db);
  366. $trackid = 'int'.$object->id;
  367. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  368. if ($sall) {
  369. foreach ($fieldstosearchall as $key => $val) {
  370. $fieldstosearchall[$key] = $langs->trans($val);
  371. }
  372. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  373. }
  374. $moreforfilter = '';
  375. $parameters = array();
  376. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  377. if (empty($reshook)) {
  378. $moreforfilter .= $hookmanager->resPrint;
  379. } else {
  380. $moreforfilter = $hookmanager->resPrint;
  381. }
  382. if (!empty($moreforfilter)) {
  383. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  384. print $moreforfilter;
  385. print '</div>';
  386. }
  387. if ($massactionbutton) {
  388. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  389. }
  390. print '<div class="div-table-responsive">';
  391. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  392. print '<tr class="liste_titre_filter">';
  393. if (!empty($arrayfields['f.ref']['checked'])) {
  394. print '<td class="liste_titre">';
  395. print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
  396. print '</td>';
  397. }
  398. if (!empty($arrayfields['s.nom']['checked'])) {
  399. print '<td class="liste_titre">';
  400. print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
  401. print '</td>';
  402. }
  403. if (!empty($arrayfields['pr.ref']['checked'])) {
  404. print '<td class="liste_titre">';
  405. print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">';
  406. print '</td>';
  407. }
  408. if (!empty($arrayfields['c.ref']['checked'])) {
  409. print '<td class="liste_titre">';
  410. print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">';
  411. print '</td>';
  412. }
  413. if (!empty($arrayfields['f.description']['checked'])) {
  414. print '<td class="liste_titre">';
  415. print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
  416. print '</td>';
  417. }
  418. // Extra fields
  419. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  420. // Fields from hook
  421. $parameters = array('arrayfields'=>$arrayfields);
  422. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  423. print $hookmanager->resPrint;
  424. if (!empty($arrayfields['f.datec']['checked'])) {
  425. // Date creation
  426. print '<td class="liste_titre">';
  427. print '</td>';
  428. }
  429. if (!empty($arrayfields['f.tms']['checked'])) {
  430. // Date modification
  431. print '<td class="liste_titre">';
  432. print '</td>';
  433. }
  434. if (!empty($arrayfields['f.note_public']['checked'])) {
  435. // Note public
  436. print '<td class="liste_titre">';
  437. print '</td>';
  438. }
  439. if (!empty($arrayfields['f.note_private']['checked'])) {
  440. // Note private
  441. print '<td class="liste_titre">';
  442. print '</td>';
  443. }
  444. // Status
  445. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  446. print '<td class="liste_titre right">';
  447. $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short
  448. $liststatus = $objectstatic->statuts_short;
  449. if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
  450. unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
  451. }
  452. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1);
  453. print '</td>';
  454. }
  455. // Fields of detail line
  456. if (!empty($arrayfields['fd.description']['checked'])) {
  457. print '<td class="liste_titre">&nbsp;</td>';
  458. }
  459. if (!empty($arrayfields['fd.date']['checked'])) {
  460. print '<td class="liste_titre">&nbsp;</td>';
  461. }
  462. if (!empty($arrayfields['fd.duree']['checked'])) {
  463. print '<td class="liste_titre">&nbsp;</td>';
  464. }
  465. print '<td class="liste_titre maxwidthsearch">';
  466. $searchpicto = $form->showFilterButtons();
  467. print $searchpicto;
  468. print '</td>';
  469. print "</tr>\n";
  470. print '<tr class="liste_titre">';
  471. if (!empty($arrayfields['f.ref']['checked'])) {
  472. print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
  473. }
  474. if (!empty($arrayfields['s.nom']['checked'])) {
  475. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
  476. }
  477. if (!empty($arrayfields['pr.ref']['checked'])) {
  478. print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
  479. }
  480. if (!empty($arrayfields['c.ref']['checked'])) {
  481. print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
  482. }
  483. if (!empty($arrayfields['f.description']['checked'])) {
  484. print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
  485. }
  486. // Extra fields
  487. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  488. // Hook fields
  489. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  490. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  491. print $hookmanager->resPrint;
  492. if (!empty($arrayfields['f.datec']['checked'])) {
  493. print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  494. }
  495. if (!empty($arrayfields['f.tms']['checked'])) {
  496. print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  497. }
  498. if (!empty($arrayfields['f.note_public']['checked'])) {
  499. print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  500. }
  501. if (!empty($arrayfields['f.note_private']['checked'])) {
  502. print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  503. }
  504. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  505. print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
  506. }
  507. if (!empty($arrayfields['fd.description']['checked'])) {
  508. print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
  509. }
  510. if (!empty($arrayfields['fd.date']['checked'])) {
  511. print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
  512. }
  513. if (!empty($arrayfields['fd.duree']['checked'])) {
  514. print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
  515. }
  516. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  517. print "</tr>\n";
  518. $total = 0;
  519. $i = 0;
  520. $totalarray = array();
  521. $totalarray['nbfield'] = 0;
  522. $totalarray['val'] = array();
  523. $totalarray['val']['fd.duree'] = 0;
  524. while ($i < min($num, $limit)) {
  525. $obj = $db->fetch_object($resql);
  526. $objectstatic->id = $obj->rowid;
  527. $objectstatic->ref = $obj->ref;
  528. $objectstatic->statut = $obj->status;
  529. $objectstatic->status = $obj->status;
  530. $companystatic->name = $obj->name;
  531. $companystatic->id = $obj->socid;
  532. $companystatic->client = $obj->client;
  533. $companystatic->fournisseur = $obj->fournisseur;
  534. $companystatic->email = $obj->email;
  535. $companystatic->status = $obj->thirdpartystatus;
  536. print '<tr class="oddeven">';
  537. if (!empty($arrayfields['f.ref']['checked'])) {
  538. print "<td>";
  539. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  540. // Picto + Ref
  541. print '<td class="nobordernopadding nowrap">';
  542. print $objectstatic->getNomUrl(1);
  543. print '</td>';
  544. // Warning
  545. $warnornote = '';
  546. //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
  547. if (!empty($obj->note_private)) {
  548. $warnornote .= ($warnornote ? ' ' : '');
  549. $warnornote .= '<span class="note">';
  550. $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
  551. $warnornote .= '</span>';
  552. }
  553. if ($warnornote) {
  554. print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
  555. print $warnornote;
  556. print '</td>';
  557. }
  558. // Other picto tool
  559. print '<td width="16" class="right nobordernopadding hideonsmartphone">';
  560. $filename = dol_sanitizeFileName($obj->ref);
  561. $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
  562. $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  563. print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  564. print '</td></tr></table>';
  565. print "</td>\n";
  566. if (!$i) {
  567. $totalarray['nbfield']++;
  568. }
  569. }
  570. if (!empty($arrayfields['s.nom']['checked'])) {
  571. print '<td>';
  572. print $companystatic->getNomUrl(1, '', 44);
  573. print '</td>';
  574. if (!$i) {
  575. $totalarray['nbfield']++;
  576. }
  577. }
  578. if (!empty($arrayfields['pr.ref']['checked'])) {
  579. print '<td>';
  580. $projetstatic->id = $obj->projet_id;
  581. $projetstatic->ref = $obj->projet_ref;
  582. $projetstatic->title = $obj->projet_title;
  583. if ($projetstatic->id > 0) {
  584. print $projetstatic->getNomUrl(1, '');
  585. }
  586. print '</td>';
  587. if (!$i) {
  588. $totalarray['nbfield']++;
  589. }
  590. }
  591. if (!empty($arrayfields['c.ref']['checked'])) {
  592. print '<td>';
  593. $contratstatic->id = $obj->contrat_id;
  594. $contratstatic->ref = $obj->contrat_ref;
  595. $contratstatic->ref_customer = $obj->contrat_ref_customer;
  596. $contratstatic->ref_supplier = $obj->contrat_ref_supplier;
  597. if ($contratstatic->id > 0) {
  598. print $contratstatic->getNomUrl(1, '');
  599. print '</td>';
  600. }
  601. if (!$i) {
  602. $totalarray['nbfield']++;
  603. }
  604. }
  605. if (!empty($arrayfields['f.description']['checked'])) {
  606. print '<td>'.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).'</td>';
  607. if (!$i) {
  608. $totalarray['nbfield']++;
  609. }
  610. }
  611. // Extra fields
  612. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  613. // Fields from hook
  614. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  615. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  616. print $hookmanager->resPrint;
  617. // Date creation
  618. if (!empty($arrayfields['f.datec']['checked'])) {
  619. print '<td class="center">';
  620. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  621. print '</td>';
  622. if (!$i) {
  623. $totalarray['nbfield']++;
  624. }
  625. }
  626. // Date modification
  627. if (!empty($arrayfields['f.tms']['checked'])) {
  628. print '<td class="center">';
  629. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  630. print '</td>';
  631. if (!$i) {
  632. $totalarray['nbfield']++;
  633. }
  634. }
  635. // Note public
  636. if (!empty($arrayfields['f.note_public']['checked'])) {
  637. print '<td class="center">';
  638. print dol_escape_htmltag($obj->note_public);
  639. print '</td>';
  640. if (!$i) {
  641. $totalarray['nbfield']++;
  642. }
  643. }
  644. // Note private
  645. if (!empty($arrayfields['f.note_private']['checked'])) {
  646. print '<td class="center">';
  647. print dol_escape_htmltag($obj->note_private);
  648. print '</td>';
  649. if (!$i) {
  650. $totalarray['nbfield']++;
  651. }
  652. }
  653. // Status
  654. if (!empty($arrayfields['f.fk_statut']['checked'])) {
  655. print '<td class="right">'.$objectstatic->getLibStatut(5).'</td>';
  656. if (!$i) {
  657. $totalarray['nbfield']++;
  658. }
  659. }
  660. // Fields of detail of line
  661. if (!empty($arrayfields['fd.description']['checked'])) {
  662. print '<td>'.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1)), 48).'</td>';
  663. if (!$i) {
  664. $totalarray['nbfield']++;
  665. }
  666. }
  667. if (!empty($arrayfields['fd.date']['checked'])) {
  668. print '<td class="center">'.dol_print_date($db->jdate($obj->dp), 'dayhour')."</td>\n";
  669. if (!$i) {
  670. $totalarray['nbfield']++;
  671. }
  672. }
  673. if (!empty($arrayfields['fd.duree']['checked'])) {
  674. print '<td class="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
  675. if (!$i) {
  676. $totalarray['nbfield']++;
  677. }
  678. if (!$i) {
  679. $totalarray['type'][$totalarray['nbfield']] = 'duration';
  680. $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
  681. }
  682. $totalarray['val']['fd.duree'] += $obj->duree;
  683. }
  684. // Action column
  685. print '<td class="nowrap center">';
  686. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  687. $selected = 0;
  688. if (in_array($obj->rowid, $arrayofselected)) {
  689. $selected = 1;
  690. }
  691. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  692. }
  693. print '</td>';
  694. if (!$i) {
  695. $totalarray['nbfield']++;
  696. }
  697. print "</tr>\n";
  698. $total += $obj->duree;
  699. $i++;
  700. }
  701. // Show total line
  702. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  703. $db->free($resql);
  704. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  705. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  706. print $hookmanager->resPrint;
  707. print '</table>'."\n";
  708. print '</div>';
  709. print "</form>\n";
  710. $hidegeneratedfilelistifempty = 1;
  711. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  712. $hidegeneratedfilelistifempty = 0;
  713. }
  714. // Show list of available documents
  715. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  716. $urlsource .= str_replace('&amp;', '&', $param);
  717. $filedir = $diroutputmassaction;
  718. $genallowed = $user->rights->ficheinter->lire;
  719. $delallowed = $user->rights->ficheinter->creer;
  720. print $formfile->showdocuments('massfilesarea_interventions', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  721. } else {
  722. dol_print_error($db);
  723. }
  724. llxFooter();
  725. $db->close();