website.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  6. * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
  7. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  9. * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
  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 <http://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/societe/website.php
  26. * \ingroup website
  27. * \brief Page of web sites accounts
  28. */
  29. require '../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  35. $langs->loadLangs(array("companies","website"));
  36. $search_status=GETPOST('search_status');
  37. // Security check
  38. $id = GETPOST('id','int')?GETPOST('id','int'):GETPOST('socid','int');
  39. if ($user->societe_id) $socid=$user->societe_id;
  40. $result = restrictedArea($user, 'societe', $socid, '&societe');
  41. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  42. $sortfield = GETPOST("sortfield",'alpha');
  43. $sortorder = GETPOST("sortorder",'alpha');
  44. $page = GETPOST("page",'int');
  45. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  46. $offset = $limit * $page;
  47. $pageprev = $page - 1;
  48. $pagenext = $page + 1;
  49. if (! $sortfield) $sortfield='t.login';
  50. if (! $sortorder) $sortorder='ASC';
  51. // Initialize technical objects
  52. $object=new Societe($db);
  53. $objectwebsiteaccount=new SocieteAccount($db);
  54. $extrafields = new ExtraFields($db);
  55. $diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id;
  56. $hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array
  57. // Fetch optionals attributes and labels
  58. $extralabels = $extrafields->fetch_name_optionals_label('thirdpartyaccount');
  59. $search_array_options=$extrafields->getOptionalsFromPost('thirdpartyaccount','','search_');
  60. unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty
  61. // Initialize array of search criterias
  62. $search_all=trim(GETPOST("search_all",'alpha'));
  63. $search=array();
  64. foreach($objectwebsiteaccount->fields as $key => $val)
  65. {
  66. if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha');
  67. }
  68. // List of fields to search into when doing a "search in all"
  69. $fieldstosearchall = array();
  70. foreach($objectwebsiteaccount->fields as $key => $val)
  71. {
  72. if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label'];
  73. }
  74. // Definition of fields for list
  75. $arrayfields=array();
  76. foreach($objectwebsiteaccount->fields as $key => $val)
  77. {
  78. // If $val['visible']==0, then we never show the field
  79. if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']);
  80. }
  81. // Extra fields
  82. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  83. {
  84. foreach($extrafields->attribute_label as $key => $val)
  85. {
  86. if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
  87. }
  88. }
  89. if ($id > 0)
  90. {
  91. $result = $object->fetch($id);
  92. }
  93. /*
  94. * Actions
  95. */
  96. $parameters=array('id'=>$socid);
  97. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  98. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  99. if (empty($reshook))
  100. {
  101. // Cancel
  102. if (GETPOST('cancel','alpha') && ! empty($backtopage))
  103. {
  104. header("Location: ".$backtopage);
  105. exit;
  106. }
  107. // Selection of new fields
  108. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  109. // Purge search criteria
  110. 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
  111. {
  112. foreach($objectwebsiteaccount->fields as $key => $val)
  113. {
  114. $search[$key]='';
  115. }
  116. $toselect='';
  117. $search_array_options=array();
  118. }
  119. if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
  120. || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
  121. {
  122. $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  123. }
  124. // Mass actions
  125. $objectclass='WebsiteAccount';
  126. $objectlabel='WebsiteAccount';
  127. $permtoread = $user->rights->societe->lire;
  128. $permtodelete = $user->rights->societe->supprimer;
  129. $uploaddir = $conf->societe->dir_output;
  130. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  131. }
  132. /*
  133. * View
  134. */
  135. $contactstatic = new Contact($db);
  136. $form = new Form($db);
  137. $langs->load("companies");
  138. $title = $langs->trans("WebsiteAccounts");
  139. llxHeader('', $title);
  140. $param='';
  141. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
  142. if ($id > 0) $param.='&id='.urlencode($id);
  143. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
  144. foreach($search as $key => $val)
  145. {
  146. $param.= '&search_'.$key.'='.urlencode($search[$key]);
  147. }
  148. if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
  149. // Add $param from extra fields
  150. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  151. $head = societe_prepare_head($object);
  152. dol_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company');
  153. $linkback = '<a href="' . DOL_URL_ROOT . '/societe/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
  154. dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
  155. print '<div class="fichecenter">';
  156. print '<div class="underbanner clearboth"></div>';
  157. print '<table class="border centpercent">';
  158. // Prefix
  159. if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
  160. {
  161. print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>';
  162. }
  163. if ($object->client) {
  164. print '<tr><td class="titlefield">';
  165. print $langs->trans('CustomerCode') . '</td><td colspan="3">';
  166. print $object->code_client;
  167. if ($object->check_codeclient() != 0)
  168. print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>';
  169. print '</td></tr>';
  170. }
  171. if ($object->fournisseur) {
  172. print '<tr><td class="titlefield">';
  173. print $langs->trans('SupplierCode') . '</td><td colspan="3">';
  174. print $object->code_fournisseur;
  175. if ($object->check_codefournisseur() != 0)
  176. print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>';
  177. print '</td></tr>';
  178. }
  179. print '</table>';
  180. print '</div>';
  181. dol_fiche_end();
  182. $newcardbutton = '';
  183. if (! empty($conf->website->enabled)) {
  184. if (! empty($user->rights->societe->lire)) {
  185. $newcardbutton .= '<a class="butActionNew" href="' . DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'"><span class="valignmiddle">' . $langs->trans("AddWebsiteAccount").'</span>';
  186. $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
  187. $newcardbutton.= '</a>';
  188. } else {
  189. $newcardbutton .= '<a class="butActionNewRefused" href="#">' . $langs->trans("AddAction");
  190. $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
  191. $newcardbutton.= '</a>';
  192. }
  193. }
  194. print '<br>';
  195. // Build and execute select
  196. // --------------------------------------------------------------------
  197. $sql = 'SELECT ';
  198. foreach($objectwebsiteaccount->fields as $key => $val)
  199. {
  200. $sql.='t.'.$key.', ';
  201. }
  202. // Add fields from extrafields
  203. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
  204. // Add fields from hooks
  205. $parameters=array();
  206. $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
  207. $sql.=$hookmanager->resPrint;
  208. $sql=preg_replace('/, $/','', $sql);
  209. $sql.= " FROM ".MAIN_DB_PREFIX."societe_account as t";
  210. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_account_extrafields as ef on (t.rowid = ef.fk_object)";
  211. if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('societeaccount').")";
  212. else $sql.=" WHERE 1 = 1";
  213. $sql.=" AND fk_soc = ".$object->id;
  214. foreach($search as $key => $val)
  215. {
  216. $mode_search=(($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key]))?1:0);
  217. if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search));
  218. }
  219. if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
  220. // Add where from extra fields
  221. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  222. // Add where from hooks
  223. $parameters=array();
  224. $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
  225. $sql.=$hookmanager->resPrint;
  226. /* If a group by is required
  227. $sql.= " GROUP BY "
  228. foreach($objectwebsiteaccount->fields as $key => $val)
  229. {
  230. $sql.='t.'.$key.', ';
  231. }
  232. // Add fields from extrafields
  233. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
  234. // Add where from hooks
  235. $parameters=array();
  236. $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $objectwebsiteaccount may have been modified by hook
  237. $sql.=$hookmanager->resPrint;
  238. */
  239. $sql.=$db->order($sortfield,$sortorder);
  240. // Count total nb of records
  241. $nbtotalofrecords = '';
  242. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  243. {
  244. $result = $db->query($sql);
  245. $nbtotalofrecords = $db->num_rows($result);
  246. if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
  247. {
  248. $page = 0;
  249. $offset = 0;
  250. }
  251. }
  252. $sql.= $db->plimit($limit+1, $offset);
  253. $resql=$db->query($sql);
  254. if (! $resql)
  255. {
  256. dol_print_error($db);
  257. exit;
  258. }
  259. $num = $db->num_rows($resql);
  260. $arrayofselected=is_array($toselect)?$toselect:array();
  261. // List of mass actions available
  262. $arrayofmassactions = array(
  263. //'presend'=>$langs->trans("SendByMail"),
  264. //'builddoc'=>$langs->trans("PDFMerge"),
  265. );
  266. if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=$langs->trans("Delete");
  267. if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
  268. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  269. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  270. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  271. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  272. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  273. print '<input type="hidden" name="action" value="list">';
  274. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  275. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  276. print '<input type="hidden" name="page" value="'.$page.'">';
  277. print '<input type="hidden" name="id" value="'.$id.'">';
  278. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  279. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
  280. $topicmail="Information";
  281. $modelmail="societeaccount";
  282. $objecttmp=new SocieteAccount($db);
  283. $trackid='thi'.$object->id;
  284. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  285. if ($sall)
  286. {
  287. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  288. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
  289. }
  290. /*$moreforfilter = '';
  291. $moreforfilter.='<div class="divsearchfield">';
  292. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  293. $moreforfilter.= '</div>';*/
  294. $parameters=array();
  295. $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
  296. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  297. else $moreforfilter = $hookmanager->resPrint;
  298. if (! empty($moreforfilter))
  299. {
  300. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  301. print $moreforfilter;
  302. print '</div>';
  303. }
  304. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  305. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  306. $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  307. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  308. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  309. // Fields title search
  310. // --------------------------------------------------------------------
  311. print '<tr class="liste_titre">';
  312. foreach($objectwebsiteaccount->fields as $key => $val)
  313. {
  314. $align='';
  315. if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
  316. if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
  317. if ($key == 'status') $align.=($align?' ':'').'center';
  318. if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
  319. }
  320. // Extra fields
  321. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  322. // Fields from hook
  323. $parameters=array('arrayfields'=>$arrayfields);
  324. $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
  325. print $hookmanager->resPrint;
  326. // Action column
  327. print '<td class="liste_titre" align="right">';
  328. $searchpicto=$form->showFilterButtons();
  329. print $searchpicto;
  330. print '</td>';
  331. print '</tr>'."\n";
  332. // Fields title label
  333. // --------------------------------------------------------------------
  334. print '<tr class="liste_titre">';
  335. foreach($objectwebsiteaccount->fields as $key => $val)
  336. {
  337. $align='';
  338. if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
  339. if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
  340. if ($key == 'status') $align.=($align?' ':'').'center';
  341. if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
  342. }
  343. // Extra fields
  344. // Extra fields
  345. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  346. // Hook fields
  347. $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
  348. $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
  349. print $hookmanager->resPrint;
  350. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
  351. print '</tr>'."\n";
  352. // Detect if we need a fetch on each output line
  353. $needToFetchEachLine=0;
  354. foreach ($extrafields->attribute_computed as $key => $val)
  355. {
  356. if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object
  357. }
  358. // Loop on record
  359. // --------------------------------------------------------------------
  360. $i=0;
  361. $totalarray=array();
  362. while ($i < min($num, $limit))
  363. {
  364. $obj = $db->fetch_object($resql);
  365. if (empty($obj)) break; // Should not happen
  366. // Store properties in $object
  367. $objectwebsiteaccount->id = $obj->rowid;
  368. foreach($objectwebsiteaccount->fields as $key => $val)
  369. {
  370. if (isset($obj->$key)) $objectwebsiteaccount->$key = $obj->$key;
  371. }
  372. // Show here line of result
  373. print '<tr class="oddeven">';
  374. foreach($objectwebsiteaccount->fields as $key => $val)
  375. {
  376. $align='';
  377. if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
  378. if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
  379. if ($key == 'status') $align.=($align?' ':'').'center';
  380. if (! empty($arrayfields['t.'.$key]['checked']))
  381. {
  382. print '<td';
  383. if ($align) print ' class="'.$align.'"';
  384. print '>';
  385. if ($key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
  386. else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
  387. print '</td>';
  388. if (! $i) $totalarray['nbfield']++;
  389. if (! empty($val['isameasure']))
  390. {
  391. if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
  392. $totalarray['val']['t.'.$key] += $obj->$key;
  393. }
  394. }
  395. }
  396. // Extra fields
  397. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  398. // Fields from hook
  399. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  400. $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
  401. print $hookmanager->resPrint;
  402. // Action column
  403. print '<td class="nowrap" align="center">';
  404. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  405. {
  406. $selected=0;
  407. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  408. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  409. }
  410. print '</td>';
  411. if (! $i) $totalarray['nbfield']++;
  412. print '</tr>';
  413. $i++;
  414. }
  415. // Show total line
  416. if (isset($totalarray['pos']))
  417. {
  418. print '<tr class="liste_total">';
  419. $i=0;
  420. while ($i < $totalarray['nbfield'])
  421. {
  422. $i++;
  423. if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
  424. else
  425. {
  426. if ($i == 1)
  427. {
  428. if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>';
  429. else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
  430. }
  431. else print '<td></td>';
  432. }
  433. }
  434. print '</tr>';
  435. }
  436. // If no record found
  437. if ($num == 0)
  438. {
  439. $colspan=1;
  440. foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
  441. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  442. }
  443. $db->free($resql);
  444. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  445. $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
  446. print $hookmanager->resPrint;
  447. print '</table>'."\n";
  448. print '</div>'."\n";
  449. print '</form>'."\n";
  450. if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
  451. {
  452. $hidegeneratedfilelistifempty=1;
  453. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
  454. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  455. $formfile = new FormFile($db);
  456. // Show list of available documents
  457. $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  458. $urlsource.=str_replace('&amp;','&',$param);
  459. $filedir=$diroutputmassaction;
  460. $genallowed=$user->rights->mymodule->read;
  461. $delallowed=$user->rights->mymodule->create;
  462. print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
  463. }
  464. // End of page
  465. llxFooter();
  466. $db->close();