list.php 30 KB

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