myobject_list.php 22 KB

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