skeleton_list.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <?php
  2. /* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
  4. * Copyright (C) 2016 Jean-François Ferry <jfefe@aternatik.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file dev/skeletons/skeleton_list.php
  21. * \ingroup mymodule othermodule1 othermodule2
  22. * \brief This file is an example of a php page
  23. * Put here some comments
  24. */
  25. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
  26. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
  27. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  28. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
  29. //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
  30. //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
  31. //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
  32. //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
  33. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
  34. //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
  35. //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
  36. // Change this following line to use the correct relative path (../, ../../, etc)
  37. $res=0;
  38. if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
  39. if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
  40. if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
  41. if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
  42. if (! $res) die("Include of main fails");
  43. // Change this following line to use the correct relative path from htdocs
  44. require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
  45. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  46. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  47. dol_include_once('/mymodule/class/skeleton_class.class.php');
  48. // Load traductions files requiredby by page
  49. $langs->load("mymodule");
  50. $langs->load("other");
  51. $action=GETPOST('action','alpha');
  52. $massaction=GETPOST('massaction','alpha');
  53. $show_files=GETPOST('show_files','int');
  54. $confirm=GETPOST('confirm','alpha');
  55. $toselect = GETPOST('toselect', 'array');
  56. $id = GETPOST('id','int');
  57. $backtopage = GETPOST('backtopage');
  58. $myparam = GETPOST('myparam','alpha');
  59. $search_all=trim(GETPOST("sall"));
  60. $search_field1=GETPOST("search_field1");
  61. $search_field2=GETPOST("search_field2");
  62. $search_myfield=GETPOST('search_myfield');
  63. $optioncss = GETPOST('optioncss','alpha');
  64. // Load variable for pagination
  65. $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
  66. $sortfield = GETPOST('sortfield','alpha');
  67. $sortorder = GETPOST('sortorder','alpha');
  68. $page = GETPOST('page','int');
  69. if ($page == -1) { $page = 0; }
  70. $offset = $limit * $page;
  71. $pageprev = $page - 1;
  72. $pagenext = $page + 1;
  73. if (! $sortfield) $sortfield="t.rowid"; // Set here default search field
  74. if (! $sortorder) $sortorder="ASC";
  75. // Protection if external user
  76. $socid=0;
  77. if ($user->societe_id > 0)
  78. {
  79. $socid = $user->societe_id;
  80. //accessforbidden();
  81. }
  82. // Initialize technical object to manage context to save list fields
  83. $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'mymodulelist';
  84. // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
  85. $hookmanager->initHooks(array('mymodulelist'));
  86. $extrafields = new ExtraFields($db);
  87. // fetch optionals attributes and labels
  88. $extralabels = $extrafields->fetch_name_optionals_label('mymodule');
  89. $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
  90. // List of fields to search into when doing a "search in all"
  91. $fieldstosearchall = array(
  92. 't.ref'=>'Ref',
  93. 't.note_public'=>'NotePublic',
  94. );
  95. if (empty($user->socid)) $fieldstosearchall["t.note_private"]="NotePrivate";
  96. // Definition of fields for list
  97. $arrayfields=array(
  98. 't.field1'=>array('label'=>"Field1", 'checked'=>1),
  99. 't.field2'=>array('label'=>"Field2", 'checked'=>1),
  100. //'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
  101. 't.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500),
  102. 't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  103. //'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
  104. );
  105. // Extra fields
  106. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  107. {
  108. foreach($extrafields->attribute_label as $key => $val)
  109. {
  110. $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
  111. }
  112. }
  113. $object=new Skeleton_Class($db);
  114. /*
  115. * ACTIONS
  116. *
  117. * Put here all code to do according to value of "action" parameter
  118. */
  119. if (GETPOST('cancel')) { $action='list'; $massaction=''; }
  120. if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
  121. $parameters=array();
  122. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  123. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  124. if (empty($reshook))
  125. {
  126. // Selection of new fields
  127. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  128. // Purge search criteria
  129. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
  130. {
  131. $search_field1='';
  132. $search_field2='';
  133. $search_date_creation='';
  134. $search_date_update='';
  135. $toselect='';
  136. $search_array_options=array();
  137. }
  138. // Mass actions
  139. $objectclass='Skeleton';
  140. $objectlabel='Skeleton';
  141. $permtoread = $user->rights->skeleton->read;
  142. $permtodelete = $user->rights->skeleton->delete;
  143. $uploaddir = $conf->skeleton->dir_output;
  144. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  145. }
  146. /*
  147. * VIEW
  148. *
  149. * Put here all code to build page
  150. */
  151. $now=dol_now();
  152. $form=new Form($db);
  153. //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
  154. $help_url='';
  155. $title = $langs->trans('MyModuleListTitle');
  156. // Put here content of your page
  157. // Example : Adding jquery code
  158. print '<script type="text/javascript" language="javascript">
  159. jQuery(document).ready(function() {
  160. function init_myfunc()
  161. {
  162. jQuery("#myid").removeAttr(\'disabled\');
  163. jQuery("#myid").attr(\'disabled\',\'disabled\');
  164. }
  165. init_myfunc();
  166. jQuery("#mybutton").click(function() {
  167. init_myfunc();
  168. });
  169. });
  170. </script>';
  171. $sql = "SELECT";
  172. $sql.= " t.rowid,";
  173. $sql.= " t.field1,";
  174. $sql.= " t.field2";
  175. // Add fields from extrafields
  176. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  177. // Add fields from hooks
  178. $parameters=array();
  179. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  180. $sql.=$hookmanager->resPrint;
  181. $sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
  182. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (t.rowid = ef.fk_object)";
  183. $sql.= " WHERE 1 = 1";
  184. //$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")";
  185. if ($search_field1) $sql.= natural_search("field1",$search_field1);
  186. if ($search_field2) $sql.= natural_search("field2",$search_field2);
  187. if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall);
  188. // Add where from extra fields
  189. foreach ($search_array_options as $key => $val)
  190. {
  191. $crit=$val;
  192. $tmpkey=preg_replace('/search_options_/','',$key);
  193. $typ=$extrafields->attribute_type[$tmpkey];
  194. $mode=0;
  195. if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
  196. if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
  197. {
  198. $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
  199. }
  200. }
  201. // Add where from hooks
  202. $parameters=array();
  203. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  204. $sql.=$hookmanager->resPrint;
  205. $sql.=$db->order($sortfield,$sortorder);
  206. // Count total nb of records
  207. $nbtotalofrecords = '';
  208. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  209. {
  210. $result = $db->query($sql);
  211. $nbtotalofrecords = $db->num_rows($result);
  212. }
  213. $sql.= $db->plimit($limit+1, $offset);
  214. dol_syslog($script_file, LOG_DEBUG);
  215. $resql=$db->query($sql);
  216. if (! $resql)
  217. {
  218. dol_print_error($db);
  219. exit;
  220. }
  221. $num = $db->num_rows($resql);
  222. // Direct jump if only one record found
  223. if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
  224. {
  225. $obj = $db->fetch_object($resql);
  226. $id = $obj->rowid;
  227. header("Location: ".DOL_URL_ROOT.'/skeleton/card.php?id='.$id);
  228. exit;
  229. }
  230. llxHeader('', $title, $help_url);
  231. $arrayofselected=is_array($toselect)?$toselect:array();
  232. $param='';
  233. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  234. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  235. if ($search_field1 != '') $param.= '&amp;search_field1='.urlencode($search_field1);
  236. if ($search_field2 != '') $param.= '&amp;search_field2='.urlencode($search_field2);
  237. if ($optioncss != '') $param.='&optioncss='.$optioncss;
  238. // Add $param from extra fields
  239. foreach ($search_array_options as $key => $val)
  240. {
  241. $crit=$val;
  242. $tmpkey=preg_replace('/search_options_/','',$key);
  243. if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
  244. }
  245. $arrayofmassactions = array(
  246. 'presend'=>$langs->trans("SendByMail"),
  247. 'builddoc'=>$langs->trans("PDFMerge"),
  248. );
  249. if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
  250. if ($massaction == 'presend') $arrayofmassactions=array();
  251. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  252. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  253. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  254. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  255. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  256. print '<input type="hidden" name="action" value="list">';
  257. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  258. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  259. print '<input type="hidden" name="page" value="'.$page.'">';
  260. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  261. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
  262. if ($sall)
  263. {
  264. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  265. print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
  266. }
  267. $moreforfilter = '';
  268. $moreforfilter.='<div class="divsearchfield">';
  269. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  270. $moreforfilter.= '</div>';
  271. $parameters=array();
  272. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  273. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  274. else $moreforfilter = $hookmanager->resPrint;
  275. if (! empty($moreforfilter))
  276. {
  277. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  278. print $moreforfilter;
  279. print '</div>';
  280. }
  281. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  282. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  283. print '<div class="div-table-responsive">';
  284. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  285. // Fields title
  286. print '<tr class="liste_titre">';
  287. // LIST_OF_TD_TITLE_FIELDS
  288. //if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
  289. //if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
  290. // Extra fields
  291. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  292. {
  293. foreach($extrafields->attribute_label as $key => $val)
  294. {
  295. if (! empty($arrayfields["ef.".$key]['checked']))
  296. {
  297. $align=$extrafields->getAlignFlag($key);
  298. $sortonfield = "ef.".$key;
  299. if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
  300. print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
  301. }
  302. }
  303. }
  304. // Hook fields
  305. $parameters=array('arrayfields'=>$arrayfields);
  306. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  307. print $hookmanager->resPrint;
  308. if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  309. if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  310. //if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
  311. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  312. print '</tr>'."\n";
  313. // Fields title search
  314. print '<tr class="liste_titre">';
  315. // LIST_OF_TD_TITLE_SEARCH
  316. //if (! empty($arrayfields['t.field1']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field1" value="'.$search_field1.'" size="10"></td>';
  317. //if (! empty($arrayfields['t.field2']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field2" value="'.$search_field2.'" size="10"></td>';
  318. // Extra fields
  319. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  320. {
  321. foreach($extrafields->attribute_label as $key => $val)
  322. {
  323. if (! empty($arrayfields["ef.".$key]['checked']))
  324. {
  325. $align=$extrafields->getAlignFlag($key);
  326. $typeofextrafield=$extrafields->attribute_type[$key];
  327. print '<td class="liste_titre'.($align?' '.$align:'').'">';
  328. if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
  329. {
  330. $crit=$val;
  331. $tmpkey=preg_replace('/search_options_/','',$key);
  332. $searchclass='';
  333. if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
  334. if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
  335. print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
  336. }
  337. print '</td>';
  338. }
  339. }
  340. }
  341. // Fields from hook
  342. $parameters=array('arrayfields'=>$arrayfields);
  343. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  344. print $hookmanager->resPrint;
  345. if (! empty($arrayfields['t.datec']['checked']))
  346. {
  347. // Date creation
  348. print '<td class="liste_titre">';
  349. print '</td>';
  350. }
  351. if (! empty($arrayfields['t.tms']['checked']))
  352. {
  353. // Date modification
  354. print '<td class="liste_titre">';
  355. print '</td>';
  356. }
  357. /*if (! empty($arrayfields['u.statut']['checked']))
  358. {
  359. // Status
  360. print '<td class="liste_titre" align="center">';
  361. print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
  362. print '</td>';
  363. }*/
  364. // Action column
  365. print '<td class="liste_titre" align="right">';
  366. $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
  367. print $searchpicto;
  368. print '</td>';
  369. print '</tr>'."\n";
  370. // Detect if we need a fetch on each output line
  371. $needToFetchEachLine=0;
  372. foreach ($extrafields->attribute_computed as $key => $val)
  373. {
  374. if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object
  375. }
  376. $i=0;
  377. $totalarray=array();
  378. while ($i < min($num, $limit))
  379. {
  380. $obj = $db->fetch_object($resql);
  381. if ($obj)
  382. {
  383. // Show here line of result
  384. print '<tr class="oddeven">';
  385. // LIST_OF_TD_FIELDS_LIST
  386. /*
  387. if (! empty($arrayfields['t.field1']['checked']))
  388. {
  389. print '<td>'.$obj->field1.'</td>';
  390. if (! $i) $totalarray['nbfield']++;
  391. }
  392. if (! empty($arrayfields['t.field2']['checked']))
  393. {
  394. print '<td>'.$obj->field2.'</td>';
  395. if (! $i) $totalarray['nbfield']++;
  396. }*/
  397. // Extra fields
  398. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  399. {
  400. foreach($extrafields->attribute_label as $key => $val)
  401. {
  402. if (! empty($arrayfields["ef.".$key]['checked']))
  403. {
  404. print '<td';
  405. $align=$extrafields->getAlignFlag($key);
  406. if ($align) print ' align="'.$align.'"';
  407. print '>';
  408. $tmpkey='options_'.$key;
  409. print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
  410. print '</td>';
  411. if (! $i) $totalarray['nbfield']++;
  412. }
  413. }
  414. }
  415. // Fields from hook
  416. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  417. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  418. print $hookmanager->resPrint;
  419. // Date creation
  420. if (! empty($arrayfields['t.datec']['checked']))
  421. {
  422. print '<td align="center">';
  423. print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
  424. print '</td>';
  425. if (! $i) $totalarray['nbfield']++;
  426. }
  427. // Date modification
  428. if (! empty($arrayfields['t.tms']['checked']))
  429. {
  430. print '<td align="center">';
  431. print dol_print_date($db->jdate($obj->date_update), 'dayhour');
  432. print '</td>';
  433. if (! $i) $totalarray['nbfield']++;
  434. }
  435. // Status
  436. /*
  437. if (! empty($arrayfields['u.statut']['checked']))
  438. {
  439. $userstatic->statut=$obj->statut;
  440. print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
  441. }*/
  442. // Action column
  443. print '<td class="nowrap" align="center">';
  444. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  445. {
  446. $selected=0;
  447. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  448. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  449. }
  450. print '</td>';
  451. if (! $i) $totalarray['nbfield']++;
  452. print '</tr>';
  453. }
  454. $i++;
  455. }
  456. // Show total line
  457. if (isset($totalarray['totalhtfield']))
  458. {
  459. print '<tr class="liste_total">';
  460. $i=0;
  461. while ($i < $totalarray['nbfield'])
  462. {
  463. $i++;
  464. if ($i == 1)
  465. {
  466. if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
  467. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  468. }
  469. elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
  470. elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>';
  471. elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>';
  472. else print '<td></td>';
  473. }
  474. print '</tr>';
  475. }
  476. $db->free($resql);
  477. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  478. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  479. print $hookmanager->resPrint;
  480. print '</table>'."\n";
  481. print '</div>'."\n";
  482. print '</form>'."\n";
  483. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
  484. {
  485. // Show list of available documents
  486. $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  487. $urlsource.=str_replace('&amp;','&',$param);
  488. $filedir=$diroutputmassaction;
  489. $genallowed=$user->rights->facture->lire;
  490. $delallowed=$user->rights->facture->lire;
  491. print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
  492. }
  493. else
  494. {
  495. print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
  496. }
  497. // End of page
  498. llxFooter();
  499. $db->close();